datagridview headers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am using VS 2005 and I want to know if it is possible to override the
onPaint() method of the header of the datagrid columns

and if it is possible how can I do it?

Thanks a lot for your attention
 
"Diogo Alves - Software Developer"
Hi,

I am using VS 2005 and I want to know if it is possible to override the
onPaint() method of the header of the datagrid columns

and if it is possible how can I do it?

Thanks a lot for your attention

Handle the CellPainting event. RowIndex will be -1 for row headers and
ColumnIndex will be -1 for column headers. The following example just paints
all header cells in solid red.

private void itemDataGridView_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
e.Graphics.FillRectangle(Brushes.Red, e.CellBounds);
e.Handled = true;
}
}

Chris Jobson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top