We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Image in header

Thread ID:





48719 Sep 4,2006 02:38 AM UTC Sep 5,2006 06:22 AM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On September 4, 2006 02:38 AM UTC


I would like to add a image in a GridControl header as shown in the attached file.

Please help!



Administrator [Syncfusion]
Replied On September 4, 2006 04:11 AM UTC

Hi lim,

To put the Icon in the columnHeader from the ImageList, you will have to make the CellType as static or as a TextBox Cell and then set your ImageIndex. Please refer the below KB Article which describes about this.


Let me know if you need further assistance.


Administrator [Syncfusion]
Replied On September 4, 2006 09:14 AM UTC


it''s working, but the image is placed before the header text.. What i expected is after the header text as shown in the attched file in my first post.


Administrator [Syncfusion]
Replied On September 4, 2006 11:56 AM UTC

Hi Lim,

You can handle the DrawCell event to draw the image in a column header cell and set e.Cancel = true to handle it. See the below code snippet for more details.

//Draw Cell event.
if(e.Style.CellType == "ColumnHeader" )
e.Style.CellAppearance = GridCellAppearance.Raised;
if(e.ColIndex == 3)
string s = e.Style.Text;

e.Style.ImageList = imageList1;
e.Style.ImageIndex = 1;
e.Style.Text=" ";

//Draw the ColumnHeader cell in a Grid.
Rectangle crect = new Rectangle( e.Bounds.Location,new Size( e.Bounds.Size.Width - e.Style.ImageList.ImageSize.Width,e.Bounds.Height) );

//Draw the text in a Grid.
Rectangle irect = new Rectangle( new Point( e.Bounds.Right - e.Style.ImageList.ImageSize.Width , e.Bounds.Top + 2),e.Style.ImageList.ImageSize);
e.Graphics.DrawString(s,e.Style.Font.GdipFont,new SolidBrush(e.Style.TextColor),crect);

//Draw the image in a Grid.
e.Style.Text= s;

//to cancel the default drawing in a grid
e.Cancel = true;


Administrator [Syncfusion]
Replied On September 5, 2006 06:22 AM UTC

Hi! It''s Working!!

Thanks a lot! :)


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon