I want to remove the first row from a datagridview before it loads in the form. What I have at the moment is :
dataGridView1.Rows.Remove(dataGridViewRow[0]);
This doesn't work. Can anyone tell me how I should adapt my code for this to work?
I want to remove the first row from a datagridview before it loads in the form. What I have at the moment is :
dataGridView1.Rows.Remove(dataGridViewRow[0]);
This doesn't work. Can anyone tell me how I should adapt my code for this to work?
Perhaps you can try this one and apply it on your form load event.
if(dataGridView1.Rows.Count > 0)
dataGridView1.Rows.RemoveAt(0);
Is the datagrid databound to a collection? If so, you could exlude the first element by doing something like this:
List<string> list = GetSomeData();
dataGridView1.DataSource = list.GetRange(1, list.Count-1);
dataGridView1.DataBind();