Spread Windows Forms 12.0 Product Documentation
Adding a Tag to a Cell
Spread Windows Forms 12.0 Product Documentation > Developer's Guide > Customizing Sheet Interaction > Using Application Tags > Adding a Tag to a Cell

You can add an application tag to a cell or range of cells. If you prefer, you can associate data with any cell in the spreadsheet, or the cells in a column, a row, or the entire spreadsheet. The string data can be used to interact with a cell or to provide information to the application you create. The cell data, or cell tag, is similar to item data you can provide for the spreadsheet, columns, or rows.

The cell tag is for the application much like the cell note is for the end user. The cell note contains an extra bit of human-readable information that is useful to the end user. The cell tag allows the application to attach an extra bit of computer-readable information to a cell. The information can be whatever is useful to the application. For example, suppose the application is manually populating an unbound sheet with values from a DataTable. The application could use the cell tag to indicate the DataRow in the DataTable from which the cell value was obtained (cell tag = DataRow). As another example, the application could use the cell tag as a dirty flag (cell tag = True indicates that the cell needs to be processed).

Since the cell tag is declared as an object, it is very flexible; it can be a number, a boolean, a string, or an instance of a class.

For more information on tags, refer to the Tag property in the Cell class and the GetCellFromTag method in the SheetView class.

Using a Shortcut

Set the Tag property for the cells in the sheet of the Spread component.

Example

This example code sets the Tag property for a range of Cell objects.

C#
Copy Code
fpSpread1.Sheets[0].Cells[1, 1, 3, 3].Tag = "This is the tag that describes the value.";
fpSpread1.Sheets[0].Cells[1, 1, 3, 3].Value = "Value Here";
VB
Copy Code
fpSpread1.Sheets(0).Cells(1, 1, 3, 3).Tag = "This is the tag that describes the value."
fpSpread1.Sheets(0).Cells(1, 1, 3, 3).Value = "Value Here"

Using Code

Set the Tag property for the Cell object for a range of cells.

Example

This example code sets the Tag property for a range of Cell objects.

C#
Copy Code
FarPoint.Win.Spread.Cell range1;
range1 = fpSpread1.ActiveSheet.Cells[1, 1, 3, 3];
range1.Value = "Value Here";
range1.Tag = "This is the tag that describes the value.";
VB
Copy Code
Dim range1 As FarPoint.Win.Spread.Cell
range1 = fpSpread1.ActiveSheet.Cells(1, 1, 3, 3)
range1.Value = "Value Here"
range1.Tag = "This is the tag that describes the value."