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

Current Cell Validating Firing Twice

The current cell validation event is firing twice in the attached example. To duplicate run the project, with the mouse place focus on the grid and type something in a cell and then with the mouse place focus on the text box on the form and you will notice that the messagebox invalid data appears twice. This message box is in the current cell validating event. Thanks, Steve frmSF_8948.zip

5 Replies

AD Administrator Syncfusion Team August 12, 2004 10:15 PM UTC

This appears to be caused by the dockingmanager. If you remove the dockingmanager, the problem goes away. I have forwarded it to a tools team to see if they can suggest something. Attached is your sample with a work-around. It has the grid.CausesValidation set to false. This avoids the problem, but does not validate (even once) when you click off teh grid. If you want to validate in this case, you can handle the grid.Leave event and do the validation there if the cell has been modified. The modified sample does this. frmSF_5519.zip


AD Administrator Syncfusion Team August 13, 2004 01:37 PM UTC

Thanks for the work-around, but I attempted to implement in my solution and the event is continually firing now. My solution implements the grid in a user control on a dockable panel. Please see the new example to duplicate the continual fire with the suggested workaround. (sorry for not submitting the user control first, but I thought the dockable panel was the problem and not the user control as well). Thanks, Steve frmSF2_6896.zip


AD Administrator Syncfusion Team August 13, 2004 02:31 PM UTC

Not too proud of this, but was able to work around teh problem in your sample by adding a timer to your usercontrol, and then triggerring it from the GridLeave event. The idea was to postpone trying to set teh focus back to teh grid for a few milliseconds while teh framework did what it wanted to do with teh focus. Below is teh code. Looking at the callstack, the framework goes up through all the nested controls trying to trigger validations, and it seems to do this even if an earlier validation fails. This is causing the multiple error displays. Postponing setting the focus back to the grid seems to let the framework clear itself, and seems to avoid this problem in your sample.
private void gridControl1_Leave(object sender, System.EventArgs e)
{
	if(this.gridControl1.CurrentCell.IsModified && !IsValidValue())
	{
		//this.gridControl1.Focus();
		this.timer1.Interval = 20;
		this.timer1.Enabled = true;
	}
}
private void timer1_Tick(object sender, System.EventArgs e)
{
	this.timer1.Enabled = false;
	this.gridControl1.Focus();
}


AD Administrator Syncfusion Team August 13, 2004 02:45 PM UTC

Here is a better solution suggested by Stefan. Handle the UserControl''s OnValidating event and set the grid''s CauseValidation to false. UserControl1_7404.zip


AD Administrator Syncfusion Team August 13, 2004 04:36 PM UTC

Worked like a champ!! Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon