Esempio n. 1
0
        private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ContextMenu m = new ContextMenu();
                int         currentMouseOverRow = dataGridView1.HitTest(e.X, e.Y).RowIndex;

                if (currentMouseOverRow >= 0)
                {
                    dataGridView1.Rows[currentMouseOverRow].Selected = true;

                    var editmenu = new CGridMenuItem("Edit");
                    editmenu.SelectedIndex = currentMouseOverRow;
                    editmenu.Click        += Edit_Click;
                    m.MenuItems.Add(editmenu);

                    var delmenu = new CGridMenuItem("Delete");
                    delmenu.SelectedIndex = currentMouseOverRow;
                    delmenu.Click        += Delete_Click;
                    m.MenuItems.Add(delmenu);
                }
                else
                {
                    var add = new MenuItem("Add");
                    add.Click += Add_Click;
                    m.MenuItems.Add(add);
                }
                m.Show(dataGridView1, new Point(e.X, e.Y));
            }
        }
Esempio n. 2
0
        private void dataGridView_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ((DataGridView)sender).ClearSelection();
                ((DataGridView)sender).EndEdit();
                ContextMenu m = new ContextMenu();
                int         currentMouseOverRow = ((DataGridView)sender).HitTest(e.X, e.Y).RowIndex;

                if (currentMouseOverRow >= 0)
                {
                    ((DataGridView)sender).Rows[currentMouseOverRow].Selected = true;
                    var delmenu = new CGridMenuItem("Delete");
                    delmenu.SelectedIndex = currentMouseOverRow;
                    delmenu.SelectedGrid  = ((DataGridView)sender).Name;
                    delmenu.Click        += menu_delete_click;
                    m.MenuItems.Add(delmenu);
                }
                else
                {
                    var add = new MenuItem("Add");
                    add.Click += btn_out_add_Click;
                    m.MenuItems.Add(add);
                }
                m.Show(((DataGridView)sender), new Point(e.X, e.Y));
            }
        }
Esempio n. 3
0
        private void Delete_Click(object sender, EventArgs e)
        {
            CGridMenuItem dataholder = (CGridMenuItem)sender;

            if (dataholder.SelectedIndex > -1)
            {
                DeleteRow(getRealIndex(dataholder.SelectedIndex));
            }
        }
Esempio n. 4
0
        private void Edit_Click(object sender, EventArgs e)
        {
            CGridMenuItem dataholder = (CGridMenuItem)sender;

            if (dataholder.SelectedIndex > -1)
            {
                if (selectData(dataholder.SelectedIndex))
                {
                    OpenRowEditor();
                }
            }
        }
Esempio n. 5
0
 private void Gridview_files_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         ContextMenu m = new ContextMenu();
         int         currentMouseOverRow = gridview_files.HitTest(e.X, e.Y).RowIndex;
         if (currentMouseOverRow >= 0)
         {
             gridview_files.Rows[currentMouseOverRow].Selected = true;
             var editmenu = new CGridMenuItem("Edit");
             editmenu.SelectedIndex = currentMouseOverRow;
             editmenu.Click        += Gridview_Editmenu_Click;
             m.MenuItems.Add(editmenu);
             m.Show(gridview_files, new Point(e.X, e.Y));
         }
     }
 }