Clay,
Thank you very much for your reply. It works great.
I have another problem. When I click on the column header, it is not drawing the column header as selected (with blue alpha-belnding). It draws all the rest of the rows in that column as selected. When I select multiple columns, it is drawing the rest of the columns (including headers) as selected. When I switch to another MDI window and come back, it is drawing all the selected column headers with alpha-blend selection.
Any ideas?
thanks,
- Reddy
Here is the cell renderer
---------------------------------------------
public class ReportColumnHeaderCellRenderer : GridStaticCellRenderer
{
///
/// The default font to be used in the cell header
///
public static GridFontInfo defaultFont = null;
///
/// Initializes a new ReportColumnHeaderCellRenderer object for the
/// given GridControlBase and GridCellModel.
///
///
The GridControlBase that display this cell
/// renderer
///
The GridCellModelBase that holds data for
/// this cell renderer that shoud be shared among views
public ReportColumnHeaderCellRenderer(GridControlBase grid,
GridCellModelBase cellModel)
: base(grid, cellModel)
{
}
///
/// This method is celled fro the cell renderers Draw method to draw
/// the contents of the client bounds for the cell, e.g. the text for
/// header cell
///
///
Points to the device graphics
///
Specifies the client rectangle. It
/// is the cell rectangle without buttons and borders
///
Specifies the row id
///
Specifies the column id
///
A reference to the style object of the cell
protected override void OnDraw(System.Drawing.Graphics g,
System.Drawing.Rectangle clientRectangle,
int rowIndex, int colIndex,
Syncfusion.Windows.Forms.Grid.GridStyleInfo style)
{
if (ReportColumnHeaderCellRenderer.defaultFont != null)
{
style.Font = ReportColumnHeaderCellRenderer.defaultFont;
}
Rectangle rc = clientRectangle;
base.OnDraw(g, rc, rowIndex, colIndex, style);
using(Pen blackPen = new Pen(Color.Black, 1))
{
// draw the column underline
if (colIndex != 1)
{
g.DrawLine(blackPen, rc.Left + 5, rc.Bottom-2,
rc.Right - 7, rc.Bottom-2);
}
// draw the vert resize handle
if (!Grid.PrintingMode)
{
int handleHeight = 4;
int x = rc.Right-2;
int y = (rc.Bottom - rc.Top)/2;
using(Pen grayPen = new Pen(Color.LightGray, 1))
{
g.DrawLine(grayPen, x, y-handleHeight, x, y+handleHeight);
}
}
}
}