dekevin

在datagridview中有时需要在右键点击某行的时候就选中它,那么我们只需要在datagridview的CellMonseDown事件中添加如下代码就行:

 if (e.Button == MouseButtons.Right && e.RowIndex > -1 && e.ColumnIndex > -1)
{

      (sender as DataGridView).CurrentRow.Selected = false;

      (sender as DataGridView).Rows[e.RowIndex].Selected = true;

}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-14
  • 2021-09-20
  • 2022-12-23
  • 2021-11-14
  • 2021-06-29
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2021-11-14
  • 2021-09-20
  • 2021-07-06
  • 2022-02-10
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案