Category / Section
How to load an image for a column in WinForms GridGroupingControl?
1 min read
Load an image for a column
To load an image for a column in WinForms grid grouping control, the following ways can be used,
1. QueryCellStyleInfo event.
2. Using Appearance property.
Using QueryCellStyleInfo event
In this method, the cell type of a column is changed to image cell and image can be loaded by adding an image to a list and assigned that list to ImageList Property. Particular image can be set by setting the Index of an image using ImageIndex Property.
C#
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo; void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.RowIndex > 2 && e.TableCellIdentity.ColIndex == 2) { e.Style.CellType = GridCellTypeName.Image; //image collection is stored in this list e.Style.ImageList= image; //index of the image to be added. e.Style.ImageIndex = 0; } }
VB
AddHandler Me.gridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs) If e.TableCellIdentity.RowIndex > 2 AndAlso e.TableCellIdentity.ColIndex = 2 Then e.Style.CellType = GridCellTypeName.Image 'image collection is stored in this list e.Style.ImageList= image 'index of the image to be added. e.Style.ImageIndex = 0 End If End Sub
Using Appearance property
An image can be loaded for a column by setting Appearance.AnyRecordFieldCell.CellType to image cell for specific columns.
C#
this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.Image; this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.ImageList = image; this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.ImageIndex = 0;
VB
Me.gridGroupingControl1.TableDescriptor.Columns(1).Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.Image Me.gridGroupingControl1.TableDescriptor.Columns(1).Appearance.AnyRecordFieldCell.ImageList = image Me.gridGroupingControl1.TableDescriptor.Columns(1).Appearance.AnyRecordFieldCell.ImageIndex = 0
Samples:
Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/appearance-and-formatting