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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Context-Menu on right mouse DOWN

Thread ID:





71913 Feb 20,2008 02:40 PM UTC Feb 21,2008 08:57 AM UTC WinForms 2
Tags: GridControl
Asked On February 20, 2008 02:40 PM UTC

I have to implement a context menu over a range of selected cells. In demos I've found to display a context menu, it's always invoked on the mouse up event.

contextMenu = new ContextMenuStrip();
contextMenu.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(cms_Opening);
contextMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(cms_ItemClicked);
this.ContextMenuStrip = contextMenu;

But this destroys the multiple selected cells.

How can I invoke the context menu with the mouse down event (like Excel does) whithout changing the grids selection range?

Or - if this is possible - how can I achieve that a right click does not alter the selected cells, when the context menu is invoked on the mouse up event?

Administrator [Syncfusion]
Replied On February 21, 2008 06:14 AM UTC

Hi AndreasG,

You can set the property so that a right-click will not affect the current selection settings.

this.GridControl1.Model.Options.SelectCellsMouseButtonsMask = Windows.Forms.MouseButtons.Left;

This should prevent the currently selected range from changing. If there is no selection when you click, you can get the clicked row and col using;

int row = 0;
int col = 0;
Point pt = this.GridControl1.PointToClient(Control.MousePosition);
this.GridControl1.PointToRowCol(pt, row, col);

Let us know if this is not what you needed.



Replied On February 21, 2008 08:57 AM UTC

Perfect! Thank you!


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon