现在的位置: 首页 > 综合 > 正文

DataGridView右键选中某单元格-C#

2012年10月17日 ⁄ 综合 ⁄ 共 364字 ⁄ 字号 评论关闭
//添加下面事件即可
        private void DataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    this.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
                   
                }
            }
        }

抱歉!评论已关闭.