Saving in windows form

Saving in windows form

Old forum URL: forums.lhotka.net/forums/t/9964.aspx


ksavoie posted on Thursday, January 20, 2011

Hi

We are using CSLA version 2.0 on .NET 2.0 VS2005.  We notice something and we don't know if we are the only one that this happens to and if there's a fix for it.  So here it is...

We build our Windows form no problem, we can fetch the information no problem.  When we do a modification in a field, let's say a textbox, and we don't tab out of that field (i.e. the cursor is still in the textbox I just modified) and I click my save button, the modification I made in that particular textbox does not get save.  But if I do tab out everything gets save.

This is getting a bit of a pain when I'm testing.  I have to make sure that I tab out of the field or click out of the field for the changes to be saved.

Is there a work around for this issue?

We don't want to change to CSLA Version 3, because everything is working fine for now and we are too advanced in our project to switch now...  We will be upgrading later on.

Thanks

Kat

 

reagan123 replied on Thursday, January 20, 2011

I'm not sure if this is a Windows issue or a CSLA issue, but there is one thing you can maybe look at.  What is the DataSourceUpdateMode on your Windows forms controls?  Try changing them to "OnPropertyChanged" if that is not what they are set as to see if this helps.

Hopefully someone with more knowledge will come along to help, but I'd look at this first.

JonnyBee replied on Thursday, January 20, 2011

Verify that your Save button has "CausesValidation" set to True.

When databinding is set to use OnValidation (default) as updatemode then it is when you leave the input control and another control that has "CausesValidation" get focus that the value is actually written to the databound property.

You can read more about databinding in the Databinding FAQ

 

ajj3085 replied on Friday, January 21, 2011

ksavoie
We don't want to change to CSLA Version 3, because everything is working fine for now and we are too advanced in our project to switch now...  We will be upgrading later on.

Just be aware that there are a lot of databinding fixes in the latest 3.x version of Csla.

That said, what you're seeing is normal.  Clicking a toolbar button does NOT cause the focus to change.  This is by design and a feature of the toolbar.  A workaround which should help is calling Validate on your form before you try to save, and this should trigger the desired behavior.

ksavoie replied on Monday, January 24, 2011

Will try that out for sure and get back to you

Thanks

Kat

lukky replied on Tuesday, January 25, 2011

Kat,

Is your save button part of a toolbar ? If so, then it's a "lightweight" control that doesn't steal focus from the previous control, and as such doesn't trigger the validation on your TextBox. Been bitten by that one before.

As mentioned, make sure you call Validate() in your Save button's handler.

Cheers

Copyright (c) Marimer LLC