3

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 them to go away?

About Column Headers:

4) Can I change their colour?

Thanks in advance.

alexxx
  • 1,171
  • 3
  • 12
  • 17
  • http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx All i would tell you is on here if you click on the row headers and column headers styles members and take a look around. There's plenty of information on the docs – Daniel Casserly Sep 13 '11 at 10:23
  • Thanks Daniel, I have already played around with the properites, but no luck. Thanks for the link also, but except that I had already seen it, I did not find answers about my questions there. – alexxx Sep 13 '11 at 10:49
  • I have solved the 2) and 4) question, setting the EnableHeadersVisualStyles property to true. Help is still needed about questions 1) and 3) and would be greatly appreciated. – alexxx Sep 13 '11 at 10:58
  • I found an answer on 1) using the following thread: http://stackoverflow.com/questions/710064/adding-text-to-datagridview-row-header. Now I only need to make this ugly arrow go away (question 3). – alexxx Sep 13 '11 at 11:05
  • Sorry, i know i have read something on that recently but it has never been an issue for myself. Of course other than stopping the grid from being able to sort but i gather that is not what you want. Sorry for not being more helpful – Daniel Casserly Sep 13 '11 at 12:49
  • That's OK man, I had already seen that link, you couldn't know that. Thanks for the responce anyway, nothing to worry about. – alexxx Sep 13 '11 at 13:01

1 Answers1

2

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;
    }
}
Amar Palsapure
  • 9,590
  • 1
  • 27
  • 46