﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Issues with saving new records</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 12:30:05 GMT</lastBuildDate><ttl>20</ttl><item><title>Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6188.aspx</link><description>When designing a form, one of our requirements is to allow the end user to enter text such as "Police Uniform" for a description.&amp;nbsp; However if the user types "Police Uniform&amp;nbsp;&amp;nbsp;&amp;nbsp; " (spaces), we want to trim the field.&amp;nbsp; So I turn on Trim Right in the BO.&amp;nbsp; Now I cannot type a space after the letter "e" in police.&amp;nbsp; &lt;/P&gt;&lt;P&gt;So I was advised to change the BindingUpdateMode to "OnValidation".&amp;nbsp; Now when I add a new record, type in a description like above, the description is NOT saved and is blank in the database and is displayed as blank on the UI form!&lt;/P&gt;&lt;P&gt;What gives?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Tue, 30 Jan 2007 09:31:16 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6420.aspx</link><description>You can raise the event from within the control by calling Me.OnValidating() or Me.OnValidated().&amp;nbsp; However, those methods are protected, so you will have to create your own textbox control and create public methods that call the protected methods.&amp;nbsp; Or you can use reflection to get the MethodInfo and invoke it on the control.&amp;nbsp; Reflection is slow and requires a good bit of code to execute a single method, but you can do it from anywhere.</description><pubDate>Tue, 30 Jan 2007 09:31:16 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6419.aspx</link><description>OK, so how do I manually fire the event(s) in the BeforeSave?&lt;/P&gt;&lt;P&gt;So far I have:&lt;/P&gt;&lt;P&gt;For Each lcControl As Control In Me.Controls&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHAT GOES HERE?&lt;BR&gt;Next&lt;/P&gt;&lt;P&gt;I have tried RaiseEvent but it complains that I cannot call base class events directly.&lt;/P&gt;&lt;P&gt;Ideas?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Tue, 30 Jan 2007 09:27:24 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6417.aspx</link><description>I'm not sure whether there is a MS knowledge base article on the problem.&amp;nbsp; From what I have been able to tell personally, if you change the focus from one control to another control, the event fires.&amp;nbsp; 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.&amp;nbsp; 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.&amp;nbsp;</description><pubDate>Tue, 30 Jan 2007 09:23:24 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6415.aspx</link><description>Yes I can see via the debugger the setvalue is not being reached.&amp;nbsp; Has this issue been reported to Microsoft and is there a knowledge base article that details this behavior?&amp;nbsp; It would be helpful to me so I can present it to the higher ups.&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Tue, 30 Jan 2007 09:13:28 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6412.aspx</link><description>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.&amp;nbsp; 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.&amp;nbsp;</description><pubDate>Tue, 30 Jan 2007 08:45:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6409.aspx</link><description>Hello,&lt;/P&gt;&lt;P&gt;I am trying to prove that the validated event is indeed not firing.&amp;nbsp; The original thread was about data saving and the OnValidation setting.&amp;nbsp; I added message boxes to the LostFocus event and the Validated for the textbox not updating when the BindingUpdateMode is set to OnValidation.&lt;/P&gt;&lt;P&gt;The message boxes both&amp;nbsp;display regardless if I tab out of the control or go directly and click the SAVE button on the maintenance form.&amp;nbsp; Where in the .NET framework is this a problem?&amp;nbsp; Is it internal or something that can be corrected via code?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Tue, 30 Jan 2007 08:21:56 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6398.aspx</link><description>(Sorry I posted this in the wrong newsgroup (issues))&lt;/P&gt;&lt;P&gt;I am adding the code to BeforeSave as you suggested.&amp;nbsp; How do I fire a validate event for controls correctly so the BO properties get updated with the new values?&lt;/P&gt;&lt;P&gt;For Each lcItem As Control In Me.Controls&lt;BR&gt;What goes here? I do not see an lcItem.Validate() option&lt;BR&gt;Next&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Mon, 29 Jan 2007 11:12:15 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6380.aspx</link><description>If you change the textboxes BindingUpdateMode to OnValidation, then you can use the trimming as you would like.&amp;nbsp; There is one problem though, you must validate the field before the changes are commited to the property.&amp;nbsp; So if you make a change and tab, it will definitely work.&amp;nbsp; But if you make a change and then click the Save button on a MaintenanceFormToolstrip (without tabbing), it may not fire the validation.&lt;/P&gt;&lt;P&gt;You can handle the BeforeSave event and force the textboxes to validate.&amp;nbsp;</description><pubDate>Mon, 29 Jan 2007 09:44:59 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6365.aspx</link><description>Can you give me an idea which method I should add to the BO's that would handle this?&amp;nbsp; I tried in the CheckRulesOnCurrentRow and it does not allow me to add a words with spaces.&amp;nbsp; You said it could be done in the BO OR a custom TextBox.&amp;nbsp; I would much rather take care of it at the BO level.&lt;/P&gt;&lt;P&gt;Also, if this is the functionality of the Trimming options of the framework, what good are they besides trimming left?&amp;nbsp; I assumed the trimming was handled during the "save" operation and not during entry.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Mon, 29 Jan 2007 07:55:27 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6274.aspx</link><description>You're wanting an automated solution for something that will take some engineering.&amp;nbsp; This will have to be done at the BO level or require a change to the textbox control.&amp;nbsp; You can create your own textbox by inheriting the StrataFrame textbox.&amp;nbsp; In the Validating event you could manage this.&amp;nbsp; (I would recommend having a property to determine whether or not to do anything.</description><pubDate>Thu, 25 Jan 2007 18:21:37 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6260.aspx</link><description>Trent,&lt;/P&gt;&lt;P&gt;You are correct.&amp;nbsp; I cannot type something like "Police Officer" because the BO keeps trimming the space much like setting it up via the Business Object Mapper.&lt;/P&gt;&lt;P&gt;So what do you suggest?&amp;nbsp; Here is what I want:&lt;/P&gt;&lt;P&gt;User types "Police Man&amp;nbsp;&amp;nbsp;&amp;nbsp; " (trailing spaces)&lt;/P&gt;&lt;P&gt;We automatically trim the field to "Police Man"&lt;/P&gt;&lt;P&gt;Ideas?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Thu, 25 Jan 2007 15:57:32 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6258.aspx</link><description>Yep, that is what I'm saying.  :D&lt;br&gt;
&lt;br&gt;
Why not just add an event handler automatically to handle the CheckRulesOnCurrentRow in the designer?  The user could have another handler. They would just have to be clear that trimmed fields might or might not yet be trimmed.</description><pubDate>Thu, 25 Jan 2007 15:12:19 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6253.aspx</link><description>I think what Greg is saying, instead of doing the Trim'ing the way StrataFrame currently does it, why not add code to the .Designer file automatically that will .Trim each field correctly before saving the entry (Insert, Update)&amp;nbsp;based on the Trim setting in the Business Object Mapper?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Thu, 25 Jan 2007 14:19:03 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6230.aspx</link><description>In this example you would never be able to add a space.</description><pubDate>Thu, 25 Jan 2007 10:56:03 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6228.aspx</link><description>What about adding a setting in the BO Mapper that would just add the code mentioned automagically?</description><pubDate>Thu, 25 Jan 2007 10:40:43 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6220.aspx</link><description>There really isn't a whole lot we can do.&amp;nbsp; The problem you're running into is a .NET binding issue.&amp;nbsp; The .NET data binding does not always properly fire the OnValidation method, additionally, this is how the .NET data binding interacts with the control.&amp;nbsp; The problem that you're running into is a .NET issue.&lt;/P&gt;&lt;P&gt;We can add this to the "to-look-at" list, but I make no guarentees that this will change until a future release of .NET.</description><pubDate>Thu, 25 Jan 2007 10:15:47 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6219.aspx</link><description>I appreciate the workaround - however we have thousands of string fields!&amp;nbsp; Is this issue going to be addressed any time soon?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Thu, 25 Jan 2007 10:10:39 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Issues with saving new records</title><link>http://forum.strataframe.net/FindPost6210.aspx</link><description>The OnValidation DataSourceUpdateMode has issues... only certain actions within .NET cause the control to update.&amp;nbsp; If the description was the last field you entered, and you immediately click the save button after you enter the field, the validation will not fire.&amp;nbsp; Hence, we default the DataSourceUpdate mode to OnPropertyChanged.&amp;nbsp; Your best bet is probably to remove the auto-trim option from the field on the BO and trim the value within the CheckRulesOnCurrentRow event.&lt;/P&gt;&lt;P&gt;Me.fld_Description = Me.fld_Description.Trim()</description><pubDate>Thu, 25 Jan 2007 09:17:10 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>