hi!
i have a girdControl header with a image at right hand side in the header cell. I do as following:
if (e.RowIndex == 1 && e.ColIndex != 0)
{
e.Style.CellAppearance = GridCellAppearance.Raised;
if (e.ColIndex % 2 == 0)
{
string s = e.Style.Text;
e.Style.ImageList = ilDG;
e.Style.ImageIndex = 0;
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;
}
}
The problem is the header text(with image) is a bit higher than the normal one. Please see the attached file.
Please help! Thanks!
DrawCellHeader.zip