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

Ignoring selections on rows

Thread ID:

Created:

Updated:

Platform:

Replies:

7082 Sep 11,2003 11:10 AM UTC Sep 11,2003 11:28 AM UTC WinForms 1
loading
Tags: GridControl
Jimmy
Asked On September 11, 2003 11:10 AM UTC

I am trying to do some special handling of selections with the SelectionChanging and SelectionChanged events. I am using the: ListBoxSelectionMode = SelectionMode.MultiExtended; My SelectionChanged code looks something like this (simplyfied): if ( e.Range.Top == 2 ) { e.Cancel = true; } Now the problem is that if my previous selection was say row 3 and 4 and I click row 2. The previous selection is cleared. I'd like to just ignore the click on row 2 and keep the valid selection (3,4). I am sure that must be something simple. Thanks

Administrator [Syncfusion]
Replied On September 11, 2003 11:28 AM UTC

In addition to cancelling the new selection, you also have to cancel the de-selection of the old range which you use e.Range.IsEmpty to test for.
private void gridControl1_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
	if(e.Range.IsEmpty && e.ClickRange.IntersectsWith(GridRangeInfo.Row(2)))
		e.Cancel = true;
	else if(e.Range.IntersectsWith(GridRangeInfo.Row(2)))
		e.Cancel = true;
}

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.

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

;