For some reason, the row header is being automatically set to the same value that appears in the adjacent cell in the first column.

I can set and get HeaderCell.Value, but it has no effect on what is displayed.

If I (manually or programmatically) enter:
	Length	Radius
Obj 1	53	79      
Obj 2	N/A	102

I end up with:
	Length	Radius
53	53	79      
N/A	N/A	102

I thought that this might be a side effect of attaching it to a DataTable ( dataGridView1.DataSource = table; ), but I removed this line of code and the issue remained.

Any ideas?

What is a row header? Aren't the values you are showing as being incorrect really just incorrect cell values in the first column without a column heading?

LOL, I guess there are row headers... I just did the following to test using it and it worked:

private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            dataGridView1.Rows[e.RowIndex].HeaderCell.Value = "Obj " + e.RowIndex;
        }

So, how are you doing it?

The code

dataGridView1.Rows[0].HeaderCell.Value = "test";// line[0];
dataGridView1.RowHeadersVisible = true;

wouldn't work in either the form initialization or load sections, even though the row headers were already set to visible.

I tried pasting in code similar to that which you posted in your response, but it still didn't work either so I forgot about it. Later, it started working and caused the artifact I mentioned in my first post (before your reply I was starting to think that the examples I found on various message boards might be referring to earlier versions of c# or .NET).

The funny thing is that my problems went away when I tried reversing the order of the lines:

dataGridView1.Rows[0].HeaderCell.Value = "test";// line[0];
dataGridView1.RowHeadersVisible = true;

Now I can't even duplicate the original issue and I no longer even need to programmatically set RowHeadersVisible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.