1

4 列の DataGridView があります。

ユーザーが行をダブルクリックすると、クリックした行の 1 列目からデータを取得したいと考えています。

    private void ticketsDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        MessageBox.Show("Row " + e.RowIndex); // gets me the row selected

    }

選択した行の列を取得するにはどうすればよいですか?

4

1 に答える 1

4

DataGridView.Rowsプロパティを見てください

ダブルクリックイベントでこれを試してください。

DataGridViewRow row =dataGridView.Rows[0];

string someStringColumnValue = (string)row.Cells[0].Value;

参照:C#-DataGridView.RowsをループするためのLambda構文

于 2012-04-13T14:47:20.810 に答える