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
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!
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
AD
Administrator
Syncfusion Team
September 5, 2006 06:22 AM UTC
Hi! It''s Working!!
Thanks a lot! :)