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.

Context-Menu on right mouse DOWN

Thread ID:

Created:

Updated:

Platform:

Replies:

71913 Feb 20,2008 09:40 AM Feb 21,2008 03:57 AM Windows Forms 2
loading
Tags: GridControl
AndreasG
Asked On February 20, 2008 09:40 AM

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 01:14 AM

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.


AndreasG
Replied On February 21, 2008 03:57 AM

Perfect! Thank you!


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.

;