for (int i = 0; i < dataGridView1.SelectedRows.Count;i++ )
{
dataGridView1.SelectedRows[i].Cells["ID"].Value.ToString();
}
返回选中行的"ID"列的值
有时候DGV用Index会错位
很基本的语法哦,楼主要加油啦。
dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count != 0)
{
for (int i = 0; i < dataGridView.SelectedRows.Count;i++ )
{
dataGridView.Rows.Remove(dataGridView.SelectedRows[i]);
}
}
}