)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to replace the default RowHeader triangle icon with another icon in WinForms GridControl or GridDataBoundGrid?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: February 11, 2020

Replace the default rowheader triangle icon with another icon

By default, GridDataBoundGrid displays a triangle in the row header cell of the currently selected row. Refer to the following screenshot.

Show the rowheader with triangle icon

Solution

You can achieve this by changing the row header BaseStyleMap to Header and handling the PrepareViewStyleInfo events. In PrepareViewStyleInfo, you can also change the e.Style.Text (for text) or the e.Style.BackgroundImage (for images).

Refer to the following code example for changing BaseStyleMap.

C#

private void Form1_Load(object sender, System.EventArgs e)
{
  this.gridDataBoundGrid1.BaseStylesMap["Row Header"].StyleInfo.CellType = "Header";
  // BackgroundImageMode used to size to fit the image within the cell rectangle.
  this.gridDataBoundGrid1.BaseStylesMap["Row Header"].StyleInfo.BackgroundImageMode = GridBackgroundImageMode.StretchImage;
  this.gridDataBoundGrid1.PrepareViewStyleInfo += new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(this.gridDataBoundGrid1_PrepareViewStyleInfo);
}

VB

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Me.gridDataBoundGrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header"
   Me.gridDataBoundGrid1.BaseStylesMap("Row Header").StyleInfo.BackgroundImageMode = GridBackgroundImageMode.StretchImage
   AddHandler gridDataBoundGrid1.PrepareViewStyleInfo, AddressOf gridDataBoundGrid1_PrepareViewStyleInfo
End Sub

Refer to the following code example for changing text or image in PrepareViewStyleInfo.

C#

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
   if(e.ColIndex == 0 && this.gridDataBoundGrid1.CurrentCell.HasCurrentCellAt(e.RowIndex))
    {
      e.Style.BackgroundImage = SystemIcons.Warning.ToBitmap();
    }
}

VB

Private Sub gridDataBoundGrid1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles gridDataBoundGrid1.PrepareViewStyleInfo
  If e.ColIndex = 0 AndAlso   Me.gridDataBoundGrid1.CurrentCell.HasCurrentCellAt(e.RowIndex) Then
     e.Style.BackgroundImage = SystemIcons.Asterisk.ToBitmap()
  End If
End Sub

The following screenshot displays the RowHeader replaced with another image and text.

Show the rowheader replaced with different image

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/WF-14478_How_to_change_RowHeaderIcon-187232645.zip

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.

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon