怎样右击DataGridView行时,选中这行的数据啊?
怎样右击DataGridView行时,选中这行的数据啊?
------解决方案--------------------private void dataGridView1_CellMouseUp(object sender, System.Windows.Forms.DataGridViewCellMouseEventArgs e)
{
if (e.Button != MouseButtons.Right || e.RowIndex < 0)
return;
if (this.dataGridView1.SelectedRows.Count > 0)
{
for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)
this.dataGridView1.SelectedRows[i].Selected = false;
}
this.dataGridView1.Rows[e.RowIndex].Selected = true;
}