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