Пример #1
0
 private void datagrid_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (groupPanel1.Visible)
     {
         return;
     }
     if (e.Button == MouseButtons.Right)
     {
         if (e.RowIndex >= 0)
         {
             //若行已是选中状态就不再进行设置
             if (dgvEX1.Rows[e.RowIndex].Selected == false)
             {
                 dgvEX1.ClearSelection();
                 dgvEX1.Rows[e.RowIndex].Selected = true;
             }
             //只选中一行时设置活动单元格
             if (dgvEX1.SelectedRows.Count == 1)
             {
                 dgvEX1.CurrentCell = dgvEX1.Rows[e.RowIndex].Cells[e.ColumnIndex];
             }
             //增加同行ToolStripMenuItem.Enabled = true;
             修改ToolStripMenuItem.Enabled = true;
             除ToolStripMenuItem.Enabled  = true;
             //SN_SN = (long)dgvEX1.Rows[e.RowIndex].Tag;
             SN_SN = Convert.ToInt64(dgvEX1.Rows[e.RowIndex].Tag);
         }
         //弹出操作菜单
         CmsMenu.Show(MousePosition.X, MousePosition.Y);
     }
 }
Пример #2
0
 private void dgvEX1_MouseDown(object sender, MouseEventArgs e)
 {
     if (groupPanel1.Visible)
     {
         return;
     }
     if (e.Button == MouseButtons.Right)
     {
         CmsMenu.Show(MousePosition.X, MousePosition.Y);
     }
 }