Articles in this section
Category / Section

Replace the default RowHeader triangle icon in WinForms Data Grid.

1 min read

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


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.


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);


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.


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();


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



I hope you enjoyed learning about how to replace the default RowHeader triangle icon with another icon in WinForms GridControl or GridDataBoundGrid.

You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our 
WinForms DataGrid
 to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment