To place an image in a column header, set the ForegroundImage and ForeGroundPicturePosition properties. These properties can be set either in the designer or in code.
In the Designer
To place an image in a column header using the C1TrueDBGrid Tasks menu:
1. Select the Last column in the grid and click it to open the C1TrueDBGrid Tasks menu.
2. Select Caption Style from the menu.
3. Click on the Images tab.
4. Click the ellipsis button next to the Foreground Image. Browse for the image and click Open.
5. Specify the position of the picture using the Foreground Picture Position drop-down box.
6. Click Ok to close the Caption Style(Last) dialog.
Alternatively, an image can also be placed in the column header at design time using the C1DisplayColumn Collection Editor.
1. Click the ellipsis button (…) next to the Splits property of the grid in the Visual Studio Properties window. The Split appears.
2. Click the ellipsis button next to the DisplayColumns property to bring up the C1DisplayColumn Collection Editor.
3. Select the column header from the list of Members on the left-hand side.
4. Expand the HeadingStyle property on the right-hand side.
5. Click the ellipsis button next to the ForegroundImage property.
6. Browse for a graphic and click Open.
7. Specify the position of the graphic using the ForeGroundPicturePosition property.
8. Click OK to close the C1DisplayColumn Collection Editor.
9. Click OK again to close the Split Collection Editor.
In Code
Add the following code to the Form_Load event:
1. Specify the image to appear in the header:
Dim bmp As New Bitmap("c:\sort.bmp")
· C#
Bitmap bmp = new Bitmap("c:\\sort.bmp");
· Delphi
Var bmp: Bitmap;
bmp := Bitmap.Create('c:\sort.bmp');
2. Specify where the image should appear:
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(1).HeadingStyle.ForegroundImage = bmp
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(1).HeadingStyle.ForeGroundPicturePosition = C1.Win.C1TrueDBGrid.ForeGroundPicturePositionEnum.LeftOfText
· C#
this.c1TrueDBGrid1.Splits[0].DisplayColumns[1].HeadingStyle.ForegroundImage = bmp;
this.c1TrueDBGrid1.Splits[0].DisplayColumns[1].HeadingStyle.ForeGroundPicturePosition = C1.Win.C1TrueDBGrid.ForeGroundPicturePositionEnum.LeftOfText;
· Delphi
Self.C1TrueDBGrid1.Splits[0].DisplayColumns[1].HeadingStyle.ForegroundImage := bmp;
Self.C1TrueDBGrid1.Splits[0].DisplayColumns[1].HeadingStyle.ForeGroundPicturePosition := C1.Win.C1TrueDBGrid.ForeGroundPicturePositionEnum.LeftOfText;
This topic illustrates the following:
In this example, the image appears to the left of the text in the header of the Last column.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |