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).
Close Icon
Unfortunately, activation email could not send to your email. Please try again.
Close Icon
close icon
Vote for your favorite ebook
Succinctly Readers Awards 2020
Syncfusion Feedback

cancel mouse click after the use of the context menu

Thread ID:





30825 Jun 24,2005 01:34 PM UTC Jun 24,2005 01:45 PM UTC WinForms 1
Tags: GridControl
Asked On June 24, 2005 01:34 PM UTC

Hello, I am using the following code to add a row to a grid using a context menu and to give the focus on the first cell of the added row (even if the grid is sorted). Well it works fine except when the user makes a right click to display the context menu on a cell of the grid. If there is no scroll at all when the new line is added then there is a click generated and the focused cell is the one on which the right click was made. Is there a way to cancel the click generated after the user has choosen an item in the context menu? Thanks in advance, Sebastien private void cm_ListChanged(object sender, ListChangedEventArgs e) { if( e.ListChangedType == ListChangedType.ItemAdded ) { grid.Refresh(); grid.Focus(); grid.CurrentCell.MoveTo( e.NewIndex+1, 1, GridSetCurrentCellOptions.ScrollInView ); } } public DataRow AddAndFocusDataRow(DataTable dataTable) { CurrencyManager cm = (CurrencyManager) grid.BindingContext[ dataTable ]; ((IBindingList)cm.List).ListChanged += new ListChangedEventHandler(cm_ListChanged); DataRow dr = dataTable.NewRow(); dataTable.Rows.Add(dr); ((IBindingList)cm.List).ListChanged -= new ListChangedEventHandler(cm_ListChanged); return dr; } grid.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left | MouseButtons.Right;

Administrator [Syncfusion]
Replied On June 24, 2005 01:45 PM UTC

Is your context menu being displayed because you are setting the COntrol.ContextMenu property, or because you are catching the mouseclick and explcitly displaying a context menu. If you are doing the latter and handling a grid event like CellClick to catch teh mouse action, then you can set e.Cancel to prevent further processing of the click. But if you are relying on the ContextMenu property, then one solution would be to remove the MouseButtons.Right from the SelectCellsMouseButtonsMask property.


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

This page will automatically be redirected to the 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