We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ContextMenuStrip DeleteRow on Grid

z
Hi guys...

I'm trying to create on ContextMenuStrip for right click on a row... so far so good with the code:

public Form1()
        {
            InitializeComponent();
            GridControl new_grid = new GridControl();           
            new_grid.Size = new Size(500, 500);
            new_grid.MouseDown += new System.Windows.Forms.MouseEventHandler(this.new_grid_MouseDown);
            this.Controls.Add(new_grid);
        }

        private void new_grid_MouseDown(object sender, MouseEventArgs e)
        {
            GridControl grid = (GridControl)sender;
            if (e.Button == MouseButtons.Right)
            {
                if (grid.Selections.Count > 0)
                {
                    foreach (GridRangeInfo selection in grid.Selections)
                    {
                        if (selection.IsRows)
                        {
                            this.ContextMenuStrip = row_menu;
                            row_menu.Show(Control.MousePosition.X, Control.MousePosition.Y);
                        }
                    }
                }
            }
        }


Now I need to pass the gridcontrol to the item clicked event of ContextMenuStrip: private void row_menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)

How can i do that ? ?

Thanks in advance.

1 Reply

VK Vinish Kumar K Syncfusion Team January 30, 2013 04:28 AM UTC

Hi Joae,

 

 

Thank you for your interest in Syncfusion products.

 

Query

Context menu Item Clicked event.

We have analyzed your query. In your update, You have provided code context menu in Mouse down event. Please refer the following codes to pass the gridControl.

 

private void formatCellsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            GridFormatCellDialog f = new GridFormatCellDialog(this.gridControl1);

            f.ShowDialog();

        }

 

<Installed_Path>\Syncfusion\EssentialStudio\10.4.0.71\Windows\Grid.Windows\Samples\2.0\Dynamic Formatting\Format Cells Demo

 

Please refer the sample from Syncfusion Essential Studio Dashboard. We have format the cell using Context menu click in sample.

 

Please let me know if you have further concerns regarding this. Please provide the sample and replication procedure if I misunderstood your sample. This will help us to provide better solution.

Let me know your concerns.

Regards,

Vinish.


Loader.
Live Chat Icon For mobile
Up arrow icon