User
User

Reputation: 24731

What index does dataGridView start at?

foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
{
    if (Int32.Parse(item.Cells[1].Value.ToString()) >= Int32.Parse(textBox4.Text) )
    {
        dataGridView1.Rows.RemoveAt(item.Index);
    }
}

I'm trying to check if the integer in the second column is at least the value in textBox4. However, nothing is removed when I run this, so I feel it's not comparing the right column.

Do C# columns count from 0 or from 1?

Upvotes: 2

Views: 5135

Answers (2)

kritikaTalwar
kritikaTalwar

Reputation: 1740

dataGridView's both rows and Columns start at 0 index

Upvotes: 1

Danieboy
Danieboy

Reputation: 4511

What index does dataGridView start at?

It starts at 0.

Upvotes: 1

Related Questions