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

How to show grid ContextMenuStrip while TextBox cell in editing

 Hi,

I am using the grid control and have a customized ContextMenuStrip, how can show this menu in TextBox type cell while the cell is in editing mode?

Thanks,

Q

1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team July 27, 2014 12:56 PM UTC

Hi Qingde,

Thank you for your interest in Syncfusion products.

If you want to show the context menu in GridControl while current cell editing mode, then please try to using the TextBox.MouseDown event in GridTextBoxCellRenderer to achieve this functionality as shown below.


Code:

            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 me know if you have any concern.

 

Regards,

Muthukumar K

Loader.
Live Chat Icon For mobile
Up arrow icon