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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Current Cell Validating Firing Twice

Thread ID:

Created:

Updated:

Platform:

Replies:

17586 Aug 12,2004 02:01 PM UTC Aug 13,2004 04:36 PM UTC Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 12, 2004 02:01 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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();
}

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On August 13, 2004 04:36 PM UTC

Worked like a champ!! Thanks!

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

;