- //添加下面事件
- private void DataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- if (e.Button == System.Windows.Forms.MouseButtons.Right)
- {
- dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
- dataGridView1.ClearSelection();
- }
- }
DataGridView右键选中某单元格(C# Winfrom)
最新推荐文章于 2020-08-30 07:49:19 发布
本文介绍了一个DataGridView控件的事件处理方法,通过监听单元格的鼠标点击事件,在用户使用鼠标右键点击DataGridView的任意单元格时,仅选中被点击的单元格并清除其他选中状态。
1212

被折叠的 条评论
为什么被折叠?



