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.

6
  • msdn.microsoft.com/en-us/library/… 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 Commented Sep 13, 2011 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
    Commented Sep 13, 2011 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
    Commented Sep 13, 2011 at 10:58
  • I found an answer on 1) using the following thread: stackoverflow.com/questions/710064/…. Now I only need to make this ugly arrow go away (question 3).
    – alexxx
    Commented Sep 13, 2011 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 Commented Sep 13, 2011 at 12:49

1 Answer 1

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;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.