Questions about Row and Column Headers of dataGridView
About Row Headers:
1) Can I write text on them?
2) Can I change their colour, so that they have different colour from all other cells?
3) Can I make this arrow that appears when I click on th开发者_JAVA技巧em to go away?
About Column Headers:
4) Can I change their colour?
Thanks in advance.
Answer to 3)
Handle the CellPainting event:
dataGridView.CellPainting +=
new DataGridViewCellPaintingEventHandler (dataGridView_CellPainting);
Then for the handler, only respond to a ColumnIndex
of "-1" (which indicates the row header):
void dataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == -1)
{
e.PaintBackground (e.CellBounds, true);
e.Handled = true;
}
}
精彩评论