1、设置选择模式

this.DataGridView_1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;

2、添加CellMouseDown事件

if (e.Button == MouseButtons.Right)
{
        if (e.RowIndex >= 0)
        {
                DataGridView_1.ClearSelection();
                DataGridView_1.Rows[e.RowIndex].Selected = true;
                DataGridView_1.CurrentCell = dgItems.Rows[e.RowIndex].Cells[e.ColumnIndex];
        }
}

相关文章:

  • 2021-06-14
  • 2021-04-14
  • 2021-08-09
  • 2021-08-01
  • 2021-08-05
  • 2022-12-23
  • 2022-03-09
猜你喜欢
  • 2022-12-23
  • 2021-05-09
  • 2021-08-10
  • 2022-12-23
  • 2021-11-09
  • 2021-07-09
相关资源
相似解决方案