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

我想檢查第二列中的整數是否至少是textBox4中的值。然而,當我運行這個時,沒有東西被刪除,所以我覺得它沒有比較右邊的列。dataGridView的起始索引是什麼?

C#列是從0還是從1開始計數?

+0

你可以設置一個斷點上,如果檢查值是多少? DataGrid中的C#列是從零開始的。 –

+0

Int32.Parse(item.Cells [1] .Value.ToString())和Int32.Parse(textBox4.Text)的值是什麼? –

+0

Ooops,我循環選定的行,而不是所有的行。 – User

回答

0

dataGridView的起始索引是什麼?

它從0開始