DataGridViewには4列と複数行のデータが格納されています。私はDataGridViewを反復処理し、から特定の列のみのセル値を取得したいと思います。このデータをメソッドに渡す必要があるためです。ここでDataGridViewの特定の列からのテキストの取得
が私のコードです:
foreach (DataGridViewRow row in this.dataGridView2.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.Value == null || cell.Value.Equals(""))
{
continue;
}
GetQuestions(cell.Value.ToString());
}
}
これはちょうどしかし、私のようなものを指定できるようにする必要があり、すべてのセルを通過するようだ:
foreach (DataGridViewRow row in this.dataGridView2.Rows)
{
foreach (DataGridViewCell cell in row.Cells[2])//Note specified column index
{
if (cell.Value == null || cell.Value.Equals(""))
{
continue;
}
GetQuestions(cell.Value.ToString());
}
}
ありがとう、長すぎるのコーディングアップして、それはそう...... :-D – Goober
それは私の時間帯で朝の真ん中ですので、あなたはに恩返しをする必要がある場合があります12時間の時間;) –
haha、私はあなたがあまりにもあると推測するところのイギリスにいます..... – Goober