0

私は以下のようなテーブルを持っています
ここに画像の説明を入力してください

これらは私がやろうとしているコードですが、希望はありませんが、そのCAid014値を取得したい

string splitter = dataGridView1.Rows[dataGridView1.RowCount].Cells[0].ToString();
MessageBox.Show(splitter); // to print what splitter got

datagridview1.rowcountを使用しているので、datagridview1.rowsが最後の行を取得します。そしてcells[0]は行の0インデックスを取得し、エラーが発生します。

CAidそのセルを取得するにはどうすればよいですか?


解決しました:私はこのような値が恋しいです

 string splitter = dataGridView1.Rows[dataGridView1.RowCount].Cells[0].value.ToString();
4

3 に答える 3

5
dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0].Value.ToString();

.Rowsはコレクションであり、配列のようにも機能し、のインデックス番号はarrays0 からN-1

于 2012-08-06T13:10:56.237 に答える
1

それを行う簡単な方法は次のとおりです:-

string splitter = (String)dataGridView1[ 0,dataGridView1.RowCount - 1].Value;

MessageBox.Show(splitter);
于 2012-08-06T13:32:03.433 に答える
0

Row Collectiondatagridview0 ベースのインデックスです。だから私は同意するdataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0].ToString();

于 2012-08-06T13:28:20.560 に答える