右击DataGrilView行事件

        private void dgvEmployee_MouseDown(object sender, MouseEventArgs e)
        {
            DataGridView.HitTestInfo rows = this.dgvEmployee.HitTest(e.X, e.Y);
            if (e.Button == MouseButtons.Right)
            {
                if (rows.RowIndex > -1 && rows.ColumnIndex > -1)
                {
               
                    this.dgvEmployee.ClearSelection();
                    this.dgvEmployee.Rows[rows.RowIndex].Selected = true;
                    this.dgvEmployee.CurrentCell = this.dgvEmployee.Rows[rows.RowIndex].Cells[rows.ColumnIndex];

                    this.cmnuEmployee_Modify.Enabled = true;
                    this.cmnuEmployee_Score.Enabled = true;
                }
                else
                {
                    this.cmnuEmployee_Modify.Enabled = false;
                    this.cmnuEmployee_Score.Enabled = false;
                }
            }
        }

 

posted @ 2013-06-13 14:47  双魂人生  阅读(285)  评论(0编辑  收藏  举报