New to Telerik UI for WinFormsStart a free 30-day trial

Tag property

Updated over 1 year ago

Each row has a Tag property of type object where you can store a custom object.

Setting the Tag property of a row

C#
 
this.radGridView1.Rows[1].Tag = "Some tag";

Setting the Tag property of cells in CellFormatting event.

C#
void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    if (e.CellElement.RowIndex % 2 == 0)
    {
        e.CellElement.RowInfo.Tag = "Some tag";
    }
    else
    {
        e.CellElement.RowInfo.Tag = "Hide row";
    }
}

Collapsing all rows with the specified tag

The most natural place to use the tag is in some of the row/cell events. For example, to make the content of certain cells invisible use the following code:

C#
void radGridView1_CellFormatting1(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    if (e.CellElement.RowInfo.Tag is String && (string)e.CellElement.RowInfo.Tag == "Hide row")
    {
        e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    }
}

Cells also have Tag property but it differs substantially from rows one because of the UI Virtualization. Cells are reused and when you scroll the tag value remains unchanged while cell data value is updated.

See Also

In this article
See Also
Not finding the help you need?
Contact Support