FlexGrid for WinForms Task-Based Help > Adding Pictures and Text to a Cell |
To add pictures and text to a cell, use the SetData and SetCellImage methods. Add the following code to the Form_Load event:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.Rows(1).Height = 90 Me.C1FlexGrid1.Cols(1).Width = 150 |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.Rows[1].Height = 90; this.c1FlexGrid1.Cols[1].Width = 150; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.SetCellImage(1, 1, Image.FromFile("c:\c1logo.bmp")) |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.SetCellImage(1, 1, Image.FromFile(@"c:\c1logo.bmp")); |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.SetData(1, 1, "ComponentOne") |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.SetData(1, 1, "ComponentOne"); |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.Styles.Normal.ImageAlign = C1.Win.C1FlexGrid.ImageAlignEnum.CenterTop Me.C1FlexGrid1.Styles.Normal.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterBottom |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.Styles.Normal.ImageAlign = C1.Win.C1FlexGrid.ImageAlignEnum.CenterTop; this.c1FlexGrid1.Styles.Normal.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterBottom; |
Your grid will look like the following with an image and text in the same cell.
![]() |
Note: To set the text on top of the picture, change the alignment of the text to CenterTop, and the alignment of the image to CenterBottom. |