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
close icon

Right Click Menu for Copy Paste

I am using a Grid Grouping Control that is bound to a List. While I am editing a Cell content, I am able to copy the content using Ctrl + C, while pasting the data if I select a part of text in the cell and Paste (Ctrl + V) it does not paste the data, however, if nothing is selected it pastes fine. Is this a bug or is there a way to correct it? Also is it possible to show the normal context menu for Cut/Copy/Paste that we usually see in any .NET control like textBox?


1 Reply

HA haneefm Syncfusion Team November 15, 2007 06:49 PM UTC

Hi Arif,

is it possible to show the normal context menu for Cut/Copy/Paste that we usually see in any .NET control like textBox?
>>>>>>
Yes, you need to set ContextMenu property to display the standard menu in a grid when you right clicked on the cell. Below are the codes:

//for showing the menu when right mouse button is clicked.
this.grid.ContextMenu = this.contextMenu1;

Regarding the Pasting Issue:
>>>>>>>>
You can handle the TableControlCurrentCellKeyDown event of the grid and call the GridTextBoxCellRenderer.Paste method to paste text when the celltext has been selected. Here are the codes:

private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if( e.Inner.Modifiers == Keys.Control
&& e.Inner.KeyCode == Keys.V )
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if( cc.IsEditing )
{
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
if( cr != null && cr.TextBox.SelectedText != string.Empty )
{
cr.TextBox.SelectedText = string.Empty;
cr.TextBox.SelectionLength = 0;
cr.Paste();
}
}
}
}


Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon