鼠標右鍵選中行

 轉自:https://www.cnblogs.com/dekevin/p/3626944.html

事件是  CellButtonDown

private void HandleCellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            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;

            }
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章