Issues with saving new records


Author
Message
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Can you give me an idea which method I should add to the BO's that would handle this?  I tried in the CheckRulesOnCurrentRow and it does not allow me to add a words with spaces.  You said it could be done in the BO OR a custom TextBox.  I would much rather take care of it at the BO level.

Also, if this is the functionality of the Trimming options of the framework, what good are they besides trimming left?  I assumed the trimming was handled during the "save" operation and not during entry. 

Ben

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
If you change the textboxes BindingUpdateMode to OnValidation, then you can use the trimming as you would like.  There is one problem though, you must validate the field before the changes are commited to the property.  So if you make a change and tab, it will definitely work.  But if you make a change and then click the Save button on a MaintenanceFormToolstrip (without tabbing), it may not fire the validation.

You can handle the BeforeSave event and force the textboxes to validate. 

Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
(Sorry I posted this in the wrong newsgroup (issues))

I am adding the code to BeforeSave as you suggested.  How do I fire a validate event for controls correctly so the BO properties get updated with the new values?

For Each lcItem As Control In Me.Controls
What goes here? I do not see an lcItem.Validate() option
Next

Thanks!

Ben

Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Hello,

I am trying to prove that the validated event is indeed not firing.  The original thread was about data saving and the OnValidation setting.  I added message boxes to the LostFocus event and the Validated for the textbox not updating when the BindingUpdateMode is set to OnValidation.

The message boxes both display regardless if I tab out of the control or go directly and click the SAVE button on the maintenance form.  Where in the .NET framework is this a problem?  Is it internal or something that can be corrected via code?

Ben

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I am not exactly sure where in .NET the problem is... however, if you place a breakpoint in the Set of your bound property, it will not always be reached depending upon how you exit out of the bound control.  You could use a tool like Reflector to look into the .NET assemblies and check the System.Windows.Forms.Binding object and see how it behaves when the DataSourceUpdateMode is set to OnValidation. 
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Yes I can see via the debugger the setvalue is not being reached.  Has this issue been reported to Microsoft and is there a knowledge base article that details this behavior?  It would be helpful to me so I can present it to the higher ups.

Ben

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'm not sure whether there is a MS knowledge base article on the problem.  From what I have been able to tell personally, if you change the focus from one control to another control, the event fires.  However, ToolStripMenuItems do not derive from Control, they derive from Component, so they cannot hold focus, and the focus is never switched from the textbox to the button, so the Validating/Validated events never fire on the textbox.  It's more of a design issue than a bug, and I'm sure that if you register a bug report with MS, they will just mark it with "By Design" and close it. 
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
OK, so how do I manually fire the event(s) in the BeforeSave?

So far I have:

For Each lcControl As Control In Me.Controls
     WHAT GOES HERE?
Next

I have tried RaiseEvent but it complains that I cannot call base class events directly.

Ideas?

Ben

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can raise the event from within the control by calling Me.OnValidating() or Me.OnValidated().  However, those methods are protected, so you will have to create your own textbox control and create public methods that call the protected methods.  Or you can use reflection to get the MethodInfo and invoke it on the control.  Reflection is slow and requires a good bit of code to execute a single method, but you can do it from anywhere.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search