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.

How to show grid ContextMenuStrip while TextBox cell in editing

Thread ID:

Created:

Updated:

Platform:

Replies:

117032 Jul 23,2014 05:12 PM Jul 27,2014 08:56 AM Windows Forms 1
loading
Tags: GridControl
Qingde Shi
Asked On July 23, 2014 05:12 PM

 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

Muthukumar Kalyanasundaram [Syncfusion]
Replied On July 27, 2014 08:56 AM

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

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.

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.

;