------解决方案-------------------- private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int x = this.dataGridView1.HitTest(e.X,e.Y).RowIndex; int y = this.dataGridView1.HitTest(e.X,e.Y).ColumnIndex; if (x != -1 && y != -1) this.dataGridView1.CurrentCell = this.dataGridView1.Rows[x].Cells[y];
}
}
------解决方案--------------------
------解决方案-------------------- 引用: private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int x = this.dataGridView1.HitTest(e.X,e.Y).RowIndex; int y = this.dataGridView1.HitTest(e.X,e.Y).ColumnIndex; if (x != -1 && y != -1) this.dataGridView1.CurrentCell = this.…
------解决方案-------------------- private DataGridViewCell clickedCell;
private void dataGridView1_MouseDown(object sender, MouseEventArgs e) { // If the user right-clicks a cell, store it for use by the shortcut menu. if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y); if (hit.Type == DataGridViewHitTestType.Cell) { clickedCell = dataGridView1.Rows[hit.RowIndex].Cells[hit.ColumnIndex]; } } }