We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the tags when the style.Tag is set through PrepareViewStyleInfo or QueryCellInfo events?

Platform: WinForms |
Control: GridControl |
Published Date: April 29, 2016 |
Last Revised Date: May 27, 2019

When a tag of a cell style is set through ‘’ event, that tag value cannot be retrieved using `this.grid[0,1].Tag`. Instead, you can make use of GetView() method for retrieving the tag in such cases.

C#:

  this.gridControl1.PrepareViewStyleInfo += gridControl1_PrepareViewStyleInfo;
}
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
    if (e.RowIndex == 0 && e.ColIndex == 1)
    {
        e.Style.Text = "Header1";
        e.Style.Tag = "Test tag";
    }
}
private void button1_Click(object sender, EventArgs e)
{
    object obj = new object();
    obj = this.gridControl1.GetViewStyleInfo(0, 1).Tag;
    MessageBox.Show(obj.ToString());
}

 

VB:

Private Me.gridControl1.PrepareViewStyleInfo += AddressOf gridControl1_PrepareViewStyleInfo
}
Private Sub gridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs)
 If e.RowIndex = 0 AndAlso e.ColIndex = 1 Then
  e.Style.Text = "Header1"
  e.Style.Tag = "Test tag"
 End If
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
 Dim obj As New Object()
 obj = Me.gridControl1.GetViewStyleInfo(0, 1).Tag
 MessageBox.Show(obj.ToString())
End Sub
 

 

Showing tag in Grid control

Samples:

C#: Set and Get a tag

VB: Set and Get a tag

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon