///
/// 在DataGridView控件的CellMouseDown事件中实现
///
///
///
private void DataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
Int rowIndex = e.RowIndex;
Int columnIndex = e.ColumnIndex;
if (rowIndex != -1 && columnIndex != -1)
{
DataGridView1.CurrentCell = DataGridView1.Rows[rowIndex].Cells[columnIndex];
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.Rows[e.RowIndex].Selected = true;
}
你看让它移动到哪里就选中哪行,这样你右击的时候那行也是选中的状态,这是否符合的需求呢。
楼上正解