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

Attaching a Context menu when the cell is in Edit mode and Non-edit mode.


Hi,


          How to Attach a Context menu when the cell is in Edit Mode and Non-edit mode?



Regards,
Ranjan VijayKumar.

1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team January 8, 2015 01:28 PM UTC

Hi Ranjan,

 

Thank you for your interest in Syncfusion products.

 

The GridControl is show the context menu, when the right click has been performed in GridControl. The GridControl does not have default property to show the context menu in editing mode. If you want the context menu also in the editing mode, then please try using GridTextBoxRenderer class in GridControl to achieve this behavior.

 

Code:

 

private void Form1_Load(object sender, EventArgs e)
{
this.gridControl1.ContextMenuStrip = this.contextMenuStrip1;
GridTextBoxCellRenderer tr = this.gridControl1.CellRenderers["TextBox"] as GridTextBoxCellRenderer;
tr.TextBox.MouseUp += new MouseEventHandler(TextBox_MouseUp);
}


void TextBox_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point pt = GridUtil.CenterPoint(this.gridControl1.CurrentCellRenderer.GetCellClientRectangle(this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex, GridStyleInfo.Default, false));
this.contextMenuStrip1.Show(this.gridControl1, pt);
}
}

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: ContextMenu_83095f9c.zip

Loader.
Live Chat Icon For mobile
Up arrow icon