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

GridControl CurrentCellValidating Event problem when stepping through code

Thread ID:

Created:

Updated:

Platform:

Replies:

67307 Aug 13,2007 10:17 PM UTC Aug 23,2007 10:25 PM UTC Windows Forms 11
loading
Tags: GridControl
Julie Levy
Asked On August 13, 2007 10:17 PM UTC

Hi -
We've noticed that when we try and step through our code, for example, to track a form level save button click, that the click event is never fired when we also have a break point set on CurrentCellValidating on a gridcontrol on the form if that event needs to be fired.
This happens when the user edits a cell but doesn't move off of that cell before hitting the save button. It only happens when stepping through the code, with the break point set in the validating event and only if the user hasn't moved off of the editted cell before hitting the button.

This seems like some sort of timing issue where the buttonclick event handler is dropped. Before i take the time to reproduce it in a sample, do you know about this behavior and if there's anything we can do to prevent it. Note that the validation is passing so my code is not setting cancel to true.

Thanks,
Julie

Ramya R [Syncfusion]
Replied On August 14, 2007 09:48 AM UTC

Hi Julie,

The CurrentCellValidating event is fired when the user tries to leave the current cell.

I was not able to reproduce the issue that you have mentioned here.

Also I have created a simple sample to test this issue and it is available in the following link.
http://websamples.syncfusion.com/samples/Grid.Windows/F67307/main.htm

In this sample, the CurrentCellValidating event gets fired when we leave the GridCell in edit mode and click the Save button.

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample or send us the reproducing steps so that we could sort out the cause of the issue and provide you a solution?

Could you also please let us know the Essential Studio version in which you are facing this issue?

Also please let me know if you have any queries.

Thanks & Regards,
Ramya.

Julie Levy
Replied On August 14, 2007 06:56 PM UTC

Hi -
your sample reproduces the problem exactly.
Put a break point inside currentcellvalidating and inside the save button click event.

Run the code, type in "Present" (so the event isn't cancelled) and hit the save button. You'll see the break point hit inside of currentcellvalidating, but not the click event. You can remove the messageboxes inside of currentcellvalidation to remove that as an issue.

The problem is only when stepping through the code.

I am using version 4.402.0.51, just like in your sample.

Thanks,
Julie

Ramya R [Syncfusion]
Replied On August 16, 2007 09:32 AM UTC

Hi Julie,

Thank you for the update.

I was able to reproduce the issue that you have mentioned here.

You can overcome this by setting the CausesValidation property of the Save button to false.

Description of CauseValidation:

The value indicating whether the control causes validation to be performed on any controls that require validation when it receives the focus.

The CurrentCellValidating event doesn't get fired until the edit mode of the cell is ended. So kindly change the code snippet of buttonSave_Click event as shown below.

private void buttonSave_Click(object sender, EventArgs e)
{
this.gridControl1.CurrentCell.EndEdit();
MessageBox.Show("Saved");
}

By performing the above changes, the buttonSave_Click gets fired first and the CurrentCellValidating event gets fired when the EndEdit() method shown in above code snippet is called.

Kindly let me know whether this helps you.

Also please let me know if you have any queries.

Thanks & Regards,
Ramya.

Julie Levy
Replied On August 16, 2007 05:01 PM UTC

Hi -
thanks for your response. While adding the EndEdit and setting the causes validation property on the button fixes the debug issue,
this produces the following exception which has no error message in it.

?ex

{""}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: null
Message: ""
Source: "Syncfusion.Grid.Windows"
StackTrace: " at Syncfusion.Windows.Forms.Grid.GridCurrentCell.EndEdit()\r\n at CurrentCellValidating.Form1.buttonSave_Click(Object sender, EventArgs e) in C:\\Documents and Settings\\jlevy\\Desktop\\Syncfusion Forum Samples\\CurrentCellValidatingSample\\Form1.cs:line 129"
TargetSite: {Void EndEdit()}

Ramya R [Syncfusion]
Replied On August 17, 2007 04:57 AM UTC

Hi Julie,

Thank you for the update.

I was able to reproduce the issue that you have mentioned here.

You can overcome this issue by using the Validate() method instead of EndEdit() method to call the CurrentCellValidating event.

Also kindly take a look at the attached sample.

You can download the sample from the below link,
http://websamples.syncfusion.com/samples/Grid.Windows/F67307-II/main.htm

Please let me know whether this helps you.

Also please let me know if you have any queries.

Thanks & Regards,
Ramya.

Julie Levy
Replied On August 17, 2007 06:48 PM UTC

Thanks,
is the original problem a bug which can be fixed? We are probably not going to change our code to manually handle validation calls just to fix a problem when debugging.
-Julie

Ramya R [Syncfusion]
Replied On August 20, 2007 08:58 AM UTC

Hi Julie,

Thank you for the update.

This is the default behavior in VisualStudio.

Setting the Causes Validation Property of the button to true fires Validation events of other controls and returns back without firing its click event when a MessageBox is used in the button click event.

Setting Causes Validation Property of the button to false calls the button click event but the Validating events of other controls are not called.

So you can overcome this only by calling Validate method in the button click event and setting the Causes Validation Property of the button to false.

Please let me know if you have any queries.

Thanks & Regards,
Ramya.

Julie Levy
Replied On August 20, 2007 10:52 PM UTC

Hi -
I notice this behavior even when there are no message boxes. And only when stepping through the code.
Thanks,
Julie

Ajish [Syncfusion]
Replied On August 21, 2007 11:24 PM UTC

Hi Julie,

You can work around the problem by setting causeValidation property of Button at form load to false and then calling Validate at button click.

Here is the modified sample for your refference,

Sample: http://websamples.syncfusion.com/samples/Grid.Windows/F67307_Aug21/main.htm

Kindly take a look and let me know if this helps in resolving your issue.

Regards,
Ajish.

Julie Levy
Replied On August 23, 2007 05:05 PM UTC

Hi -
Thanks for your response. I'm not looking to change any code at this point since the behavior only happens during debugging.
I'm just trying to find out if this behavior is a bug which Syncfusion can/will address.
Thanks,
Julie

Ajish [Syncfusion]
Replied On August 23, 2007 10:25 PM UTC

Hi Julie,

Thank you for your response. This is a default behavior of the VisualStudio.Net controls and it is not a bug with Syncfusion. The only way to resolve this issue is to make changes to your code.

Kindly let me know if you any other questions.

Regards,
Ajish.

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

;