Articles in this section
Category / Section

How to load an image for a column in WinForms GridGroupingControl?

3 mins read

Load an image for a column


To load an image for a column in WinForms GridGroupingControl, 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

The below screenshot illustrates the image loaded in the Grid Column

Add images for the column in WinForms Grid control

 











Samples:

C#: Loading an image_CS

VB: Loading an image_VB

 

Reference Link: Appearance and Formatting

 

Conclusion


I hope you enjoyed learning how to load an image for a column in GridGroupingControl.


You can refer to WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations and WinForms GridGroupingControl documentation and how to quickly get started for configuration specifications. You can also explore our WinForms GridGroupingControl example 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?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied