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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl how to get a context menu with Cut/Copy/Paste for the activated cell

Thread ID:

Created:

Updated:

Platform:

Replies:

119591 Jul 11,2015 12:33 AM UTC Jul 14,2015 11:13 AM UTC Windows Forms 3
loading
Tags: GridGroupingControl
tttmack
Asked On July 11, 2015 12:33 AM UTC

For a GridGroupingControl, I would like to be able to show a context menu(with Cut, Copy, Paste) if the active cell is a TextBox when the user performs a right click. 

How can I achieve this?

Thanks for your help!

Solai A L [Syncfusion]
Replied On July 13, 2015 05:50 AM UTC

Hi Taylour,

Thank you for your interest in Syncfusion products.

In order to add a context menu, you can it in cell edit mode while the TableControlGotFocus. Please refer the below UG link for reference.

UG Link :
http://help.syncfusion.com/ug/windows%20forms/index.html#!Documents/howtoattachacontextmenutoacellingridgroupingcontrol.htm

Please refer the below KB and installed location sample to add copy paste option in context menu.

KB Link :
https://www.syncfusion.com/kb/4672/how-to-use-your-own-context-menu-along-with-the-fieldchooser-option

Sample Link :
<Installed Location>\Syncfusion\EssentialStudio\<Version?\Windows\Grid.Grouping.Windows\Samples\Layout Customization\Cut-Copy-Paste Demo\cs

Please let us know if you have any other concerns.

Thanks & Regards,
AL.Solai.

tttmack
Replied On July 13, 2015 10:50 PM UTC

thanks but that method did not work in my case.

I was able to get things working with the following code:

private ContextMenuStrip _contextMenuStrip;

public Form1()
{
            _contextMenuStrip = new ContextMenuStrip();
            _contextMenuStrip.Items.Add("Cut", Properties.Resources.Cut, GridCutContextMenu);
            _contextMenuStrip.Items.Add("Copy", Properties.Resources.Copy, GridCopyContextMenu);
            _contextMenuStrip.Items.Add("Paste", Properties.Resources.Paste, GridPasteContextMenu);

            var textRenderer = gridGroupingControl1.TableControl.CellRenderers["TextBox"] as GridTextBoxCellRenderer;
            textRenderer.TextBox.MouseUp += GridGroupingControlTextBox_MouseUp;
}

void GridGroupingControlTextBox_MouseUp(object sender, MouseEventArgs e)
{
            if(e.Button == MouseButtons.Right)
                _contextMenuStrip.Show(Cursor.Position);
}

private void GridCutContextMenu(object sender, EventArgs e)
{
            gridGroupingControl1.TableModel.CutPaste.Cut();
}

private void GridCopyContextMenu(object sender, EventArgs e)
{
            gridGroupingControl1.TableModel.CutPaste.Copy();
}

private void GridPasteContextMenu(object sender, EventArgs e)
{
            gridGroupingControl1.TableModel.CutPaste.Paste();
}





Solai A L [Syncfusion]
Replied On July 14, 2015 11:13 AM UTC

Hi Taylour,

Thank you for your update.

We are glad to know that your issue has been resolved. Please let us know if you have any other further concerns in future.

Thanks & Regards,
Al.Solai.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;