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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SelectionMode.One does not care validation

Thread ID:





7694 Oct 6,2003 06:44 PM UTC Oct 7,2003 12:05 PM UTC WinForms 2
Tags: GridControl
Vladimir Arkhipov
Asked On October 6, 2003 06:44 PM UTC

Hi, I have a grid control with single selection mode: gridControl1.ListBoxSelectionMode = SelectionMode.One; I want to use my custom validation, so I added handler to CurrentCellValidating event It validates fine, prevents me from moving to another sell from keyboard, but mouse click moves selection to another row:(. Test code is simple like this: private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) { e.Cancel = gridControl1.CurrentCell.Renderer.ControlText.Length > 3; } Please Help!!!

Administrator [Syncfusion]
Replied On October 6, 2003 07:13 PM UTC

The validation only affects moving the current cell but not selecting cells. That's why you see this odd effect in that special case. Add the following event handler to ensure that you cannot move the selection when the current cell is invalid: void OnSelectionChanging(object sender, GridSelectionChangingEventArgs e) { if (CurrentCell.IsModified) { CurrentCell.Validate(); if (!CurrentCell.IsValid) e.Cancel = true; } } Stefan

Vladimir Arkhipov
Replied On October 7, 2003 12:05 PM UTC

Thanks a lot! It works!!!


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

Live Chat Icon For mobile
Live Chat Icon