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

SelectionMode.One does not care validation

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!!!

2 Replies

AD Administrator Syncfusion Team 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

VA Vladimir Arkhipov October 7, 2003 12:05 PM UTC

Thanks a lot! It works!!!

Live Chat Icon For mobile
Up arrow icon