Context-Menu on right mouse DOWN

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?


2 Replies

AD Administrator Syncfusion Team 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.


Regards,

Asem.



AN AndreasG February 21, 2008 08:57 AM UTC

Perfect! Thank you!


Loader.
Up arrow icon