Пример #1
0
 private void Data1_MouseClick(object sender, MouseEventArgs e)
 {
     try
     {
         var hti = Data1.HitTest(e.X, e.Y);
         if ((e.Button == MouseButtons.Right && (Data1.CurrentCell.ColumnIndex == 0 || Data1.CurrentCell.ColumnIndex == 1 || Data1.CurrentCell.ColumnIndex == 2) && Data1.CurrentCell.Value != null))
         {
             Data1.CurrentCell = Data1.Rows[hti.RowIndex].Cells[hti.ColumnIndex];
             if (hti.Type == DataGridViewHitTestType.Cell)
             {
                 MenuEliminar.Show(Data1, new Point(e.X, e.Y));
             }
         }
         if ((e.Button == MouseButtons.Right && (Data1.CurrentCell.ColumnIndex == 3 || Data1.CurrentCell.ColumnIndex == 4) && Data1.CurrentCell.Value != null))
         {
             if (hti.Type == DataGridViewHitTestType.Cell)
             {
                 MenuIVA.Show(Data1, new Point(e.X, e.Y));
             }
         }
     }
     catch
     {
     }
 }
Пример #2
0
        private void Data1_MouseDown(object sender, MouseEventArgs e)
        {
            var hti = Data1.HitTest(e.X, e.Y);

            if (hti.Type == DataGridViewHitTestType.Cell && e.Button == MouseButtons.Right)
            {
                Data1.CurrentCell = Data1.Rows[hti.RowIndex].Cells[hti.ColumnIndex];
            }
        }