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 make right-click activate AND change selection?

Thread ID:

Created:

Updated:

Platform:

Replies:

17327 Aug 5,2004 02:41 PM Aug 5,2004 03:39 PM Windows Forms 2
loading
Tags: GridControl
Daniel Chait
Asked On August 5, 2004 02:41 PM

I want right-click behavior just like Excel - when you right click within the selection, neither the current cell nor the selection will change, just a pop-up will appear. However when you right-click outside the selection, it should select the cell under the cursor and also make it active. I have a grid with ExcelLikeCurrentCell set to true, and hte following right-click handler: private void grid_MouseDown(object sender, MouseEventArgs e) { if ( e.Button == MouseButtons.Right ) { GridRangeInfo clickedRange = grid.PointToRangeInfo(new Point(e.X,e.Y)); bool clickedInSelection = false; if ( clickedRange != null ) { foreach ( GridRangeInfo info in grid.Selections.Ranges ) { if ( info.IntersectsWith(clickedRange) ) { clickedInSelection = true; break; } } if ( !clickedInSelection ) { grid.Selections.Clear(true); grid.Selections.SelectRange(clickedRange, true); grid.CurrentCell.Activate(clickedRange.Top, clickedRange.Left, GridSetCurrentCellOptions.SetFocus); } } } } Also I have a Syncfusion XPMenu popup tied to the grid. However when I right-click outside the selection, it changes the selection but doesnt appear to change the current cell also. How can I get it to do this? Thanks - Daniel

Administrator [Syncfusion]
Replied On August 5, 2004 02:52 PM

Instead of grid.Selections.Clear(true); grid.Selections.SelectRange(clickedRange, true); grid.CurrentCell.Activate(clickedRange.Top, clickedRange.Left, GridSetCurrentCellOptions.SetFocus); try grid.Selections.Clear(true); grid.CurrentCell.MoveTo(clickedRange.Top, clickedRange.Left, GridSetCurrentCellOptions.SetFocus);

Daniel Chait
Replied On August 5, 2004 03:39 PM

Thanks that did the trick.

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.

;