Image in header
hi!
I would like to add a image in a GridControl header as shown in the attached file.
Please help!
Thanks!
I would like to add a image in a GridControl header as shown in the attached file.
Please help!
Thanks!
ImageInHeader.zip
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
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.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=23
Let me know if you need further assistance.
Regards,
Haneef
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.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=23
Let me know if you need further assistance.
Regards,
Haneef
AD
Administrator
Syncfusion Team
September 4, 2006 09:14 AM UTC
hi!
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.
Thanks!
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.
Thanks!
AD
Administrator
Syncfusion Team
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) );
e.Renderer.Draw(e.Graphics,e.Bounds,e.RowIndex,e.ColIndex,e.Style);
//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.Graphics.DrawImage(e.Style.ImageList.Images[0],irect);
e.Style.Text= s;
//to cancel the default drawing in a grid
e.Cancel = true;
}
}
Thanks,
Haneef
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) );
e.Renderer.Draw(e.Graphics,e.Bounds,e.RowIndex,e.ColIndex,e.Style);
//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.Graphics.DrawImage(e.Style.ImageList.Images[0],irect);
e.Style.Text= s;
//to cancel the default drawing in a grid
e.Cancel = true;
}
}
Thanks,
Haneef
AD
Administrator
Syncfusion Team
September 5, 2006 06:22 AM UTC
Hi! It''s Working!!
Thanks a lot! :)
Thanks a lot! :)
SIGN IN To post a reply.
- 4 Replies
- 1 Participant
-
AD Administrator
- Sep 4, 2006 02:38 AM UTC
- Sep 5, 2006 06:22 AM UTC