我有一个 DataGridView (c#)。我想在双击后访问所选行的每个成员。
知道该怎么做吗?
谢谢
连接数据网格的CellDoubleClick
事件。DataGridViewCellEventArgs
包含被单击的行和列。如果行索引为 -1,则单击标题。
private void MyDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
{
// header was clicked
}
else
{
// data row was clicked, can access the row contents like this
var row = MyDataGridView.Rows[e.RowIndex];
var cell = row[0];
}
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
foreach(var item in dataGridView1.SelectedRows)
{
}
}