﻿<?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?)  » Controls not readonly when bound to a businessbindingsource</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 31 May 2026 22:26:08 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8440.aspx</link><description>[quote][b]Jerome Barnett (04/23/2007)[/b][hr]Rav-&lt;BR&gt;&lt;BR&gt;What I would do is go back to how you origianlly had you bindings set up. (Grid to BBS and Textboxes to BO)&lt;BR&gt;&lt;BR&gt;Then just handle the rowchanged or Cell Click event of the grid to tell your BO to navigate to another row.&lt;BR&gt;&lt;BR&gt;Use the EditingStateChanged and FieldPropertyChanged Eventos of the BO on your form to manage the enabled/disabled state of your buttons&lt;BR&gt;&lt;BR&gt;[quote][codesnippet]Sub EditingStateChanged&lt;BR&gt;btnOK.Enabled = myBO.IsDirty&lt;BR&gt;btnCancel.Enabled = myBO.IsDirty&lt;BR&gt;End Sub[/codesnippet][/quote]&lt;BR&gt;&lt;BR&gt;-Jerome[/quote]&lt;/P&gt;&lt;P&gt;I think the problem I ran into when doing it that way was that the grid and the texboxes were not synchronized.&amp;nbsp; The current record on the grid was not the record displayed on the textboxes.&amp;nbsp; I'll give it another shot.</description><pubDate>Mon, 23 Apr 2007 11:56:44 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8117.aspx</link><description>I'm testing out strataframe and so far it's working well.&amp;nbsp; I'm using a janus grid for navigational purposes.&amp;nbsp; Users select a record from the grid and details for that record are displayed in some textboxes.&amp;nbsp; The grid is bound to a businessbindingsource.&amp;nbsp; So far so good, here are my questions:&lt;P&gt;1.&amp;nbsp; I've discovered that if the textboxes are bound to the bo, the grid is not syncronized with the textboxes.&amp;nbsp; If I select a record on the grid, the textboxes do not reflect this change.&amp;nbsp; To fix this, I bound the textboxes to the businessbindingsource as well.&amp;nbsp; This solved the problem.&amp;nbsp; Is there an advantage to binding textboxes (and other controls) directly to the bo instead of the bindingsource?&amp;nbsp; I'd prefer to bind all my controls to the binding source since I use many 3rd party controls.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Now that I've bound the textboxes to a businessbindingsource, they are not readonly.&amp;nbsp; When bound to the bo, they are readonly until the edit button is pressed.&amp;nbsp; How can I get the same behaviour when binding to the businessbindingsource.&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; If I decide not to use edit button (and have the controls editable without users having to click the edit button), I would like the save and undo buttons to become enabled as soon as the user starts making changes (eg. user presses a key in a textbox).&amp;nbsp; First I tried using the textChanged event to set&amp;nbsp;businessobject.edit.&amp;nbsp; This didn't work because the event is fired whenever the textbox is populated.What is the best way to accomplish this behaviour?</description><pubDate>Mon, 23 Apr 2007 11:56:44 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8438.aspx</link><description>Rav-&lt;br&gt;
&lt;br&gt;
What I would do is go back to how you origianlly had you bindings set up. (Grid to BBS and Textboxes to BO)&lt;br&gt;
&lt;br&gt;
Then just handle the rowchanged or Cell Click event of the grid to tell your BO to navigate to another row.&lt;br&gt;
&lt;br&gt;
Use the EditingStateChanged and FieldPropertyChanged Eventos of the BO on your form to manage the enabled/disabled state of your buttons&lt;br&gt;
&lt;br&gt;
[quote][codesnippet]Sub EditingStateChanged&lt;br&gt;
      btnOK.Enabled = myBO.IsDirty&lt;br&gt;
      btnCancel.Enabled = myBO.IsDirty&lt;br&gt;
End Sub[/codesnippet][/quote]&lt;br&gt;
&lt;br&gt;
-Jerome</description><pubDate>Mon, 23 Apr 2007 11:02:17 GMT</pubDate><dc:creator>Jerome Barnett</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8266.aspx</link><description>[quote][b]Trent L. Taylor (04/18/2007)[/b][hr][quote]I'm curious, does everyone using this framework have their users click on edit before allowing the users to edit fields in their maintenance forms?&amp;nbsp; [/quote]&lt;P&gt;Actually, I think that you may be making life much harder than it needs to be.&amp;nbsp; We were just trying to give you some ideas based on what you posted.&amp;nbsp; There are many different reasons developers do different things and we were just trying to accomodate your current question.&lt;/P&gt;&lt;P&gt;Your current problem is that you want the state of the BO to change without tabbing....well, this actually defies how data-binding works in .NET.&amp;nbsp; The validating event is actually what triggers the binding contexts within .NET to update the bound element.&amp;nbsp; So in that example you will have to leave the field (or at least attempt to leave the field) before the underlying context is updated and referenced.&amp;nbsp; The reason for this is efficiency and speed.&amp;nbsp; If the underlying data is updated with each keystroke, you will hve a very slow performing environment....especially over time and the larger your forms (or bound controls within the environment) become.&amp;nbsp;[/quote]&lt;P&gt;I understand and agree with you.&amp;nbsp; My only concern is if a user wants to edit only 1 field, he would have to tab out before the save button will be enabled.&amp;nbsp; You're right, this is turning out more complex than it needs to be.&amp;nbsp; I will simply handle the keydown event instead of the textchanged event.&amp;nbsp; I wanted to avoid doing this because if a user right clicked on a textbox and clicked on paste&amp;nbsp;in the context menu, the save button still would not be enabled.&amp;nbsp; It's an issue i'll have to fix later.</description><pubDate>Thu, 19 Apr 2007 07:40:32 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8262.aspx</link><description>[quote]I'm curious, does everyone using this framework have their users click on edit before allowing the users to edit fields in their maintenance forms?&amp;nbsp; [/quote]&lt;/P&gt;&lt;P&gt;Actually, I think that you may be making life much harder than it needs to be.&amp;nbsp; We were just trying to give you some ideas based on what you posted.&amp;nbsp; There are many different reasons developers do different things and we were just trying to accomodate your current question.&lt;/P&gt;&lt;P&gt;Your current problem is that you want the state of the BO to change without tabbing....well, this actually defies how data-binding works in .NET.&amp;nbsp; The validating event is actually what triggers the binding contexts within .NET to update the bound element.&amp;nbsp; So in that example you will have to leave the field (or at least attempt to leave the field) before the underlying context is updated and referenced.&amp;nbsp; The reason for this is efficiency and speed.&amp;nbsp; If the underlying data is updated with each keystroke, you will hve a very slow performing environment....especially over time and the larger your forms (or bound controls within the environment) become.&amp;nbsp;</description><pubDate>Wed, 18 Apr 2007 22:28:37 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8250.aspx</link><description>[quote][b]Trent L. Taylor (04/18/2007)[/b][hr]Rav,&lt;P&gt;You can still use the TextChanged event.&amp;nbsp; Create a private variable in the form named _FormLoaded for example.&amp;nbsp; THen set this to False initially.&amp;nbsp; In the forms Shown (or load) event, set this to True.&amp;nbsp; In the TextChanged event, only call the edit if this value is set to True.[/quote]&lt;P&gt;I've implemented this and this takes care of the problem when the form is initially loaded.&amp;nbsp; However everytime&amp;nbsp;I move to a different record, the textchanged event is fired which sets the the BO to edit state again.&lt;P&gt;I would think that what i'm trying to implement would be considered very common behaviour.&amp;nbsp; I'm curious, does everyone using this framework have their users click on edit before allowing the users to edit fields in their maintenance forms?&amp;nbsp; Instead of me adding all sorts of logic to my presentation layer to accomodate this behaviour, would a much more elegant solution be if I could tell when the BO is populating bound fields and distinguish that from when the user is entering data.&amp;nbsp; Is there any way I can tell when the BO is starting to populate bound fields and when it is done?&amp;nbsp; Perhaps another editingstate that allowed us to know when the bound controls were being populated?</description><pubDate>Wed, 18 Apr 2007 18:17:37 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8222.aspx</link><description>Thank you, I will do this.&amp;nbsp; I was just checking to see if there was another "recommended" way, but this will work fine.</description><pubDate>Wed, 18 Apr 2007 09:36:46 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8219.aspx</link><description>Rav,&lt;/P&gt;&lt;P&gt;You can still use the TextChanged event.&amp;nbsp; Create a private variable in the form named _FormLoaded for example.&amp;nbsp; THen set this to False initially.&amp;nbsp; In the forms Shown (or load) event, set this to True.&amp;nbsp; In the TextChanged event, only call the edit if this value is set to True.</description><pubDate>Wed, 18 Apr 2007 09:34:07 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8211.aspx</link><description>[quote][b]Ben Chase (04/17/2007)[/b][hr]You can add a method to your business object called RaiseEditingStateChanged() and in it, you can call Me.OnEditingStateChanged().&amp;nbsp;&amp;nbsp;You can then handle the ListChanged event of the BusinessBindingSource and call the business object's RaiseEditingStateChanged() method which will cause the Save/Undo buttons to properly respect the BO as soon as you change one of the textboxes. [/quote]&lt;P&gt;Ok, i've done this and it is working except for one problem.&amp;nbsp; When I start typing in a textbox, the save/undo buttons are not enabled unless I tab to (or click on) another control (i.e the textbox loses focus).&amp;nbsp; I need the save/undo buttons enabled at the very first keystroke, not after I've typed and moved do a different control.&amp;nbsp; I tried capturing the textchanged event of the textbox and calling &lt;FONT size=2&gt;&lt;FONT color=#000000&gt;BusinessObject1.Edit&lt;/FONT&gt;&lt;/FONT&gt;, but the problem is the textchanged event is fired even when populating the textbox initially, so when my form loads the BO is already in an edit state.</description><pubDate>Tue, 17 Apr 2007 23:22:07 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8171.aspx</link><description>You can add a method to your business object called RaiseEditingStateChanged() and in it, you can call Me.OnEditingStateChanged().&amp;nbsp;&amp;nbsp;You can then handle the ListChanged event of the BusinessBindingSource and call the business object's RaiseEditingStateChanged() method which will cause the Save/Undo buttons to properly respect the BO as soon as you change one of the textboxes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;As for why the textboxes are not properly navigating with the business object, I'm not sure.&amp;nbsp; You can use CType(bbs, ICurrencyManagerProvider).CurrencyManager to get a reference to the CurrencyManager that maintains the Position property to determine the record to which the textboxes are bound.&amp;nbsp; Check when you move the CurrentRowIndex with the toolstrip buttons, check the Position property value of the CurrencyManager to see if it's changing as well.</description><pubDate>Tue, 17 Apr 2007 10:07:22 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8159.aspx</link><description>Thank you for your response, but I'm having a hard time implementing some very simple behaviour.&amp;nbsp; I've attached a sample (it uses your strataframeexample db).&amp;nbsp; Here's what I'm trying to do:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; I do not want the user to have to press the edit button in order to edit.&amp;nbsp; As soon as the user presses any key that modifies values in any of the bound textboxes, I'd like the&amp;nbsp;save and undo buttons on the toolbar&amp;nbsp;to become enabled.&amp;nbsp; Please see the example of how i'm trying to accomplish this.&amp;nbsp; It's not working...:crying:&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; In the sample, the navigation buttons on the toolstrip navigate only the textbox that's synchronized to the BO and not the textboxes synchronized to the binding source.&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;in the process evaluting strataframe for my project and would really appreciate if you could demonstrate in the sample I've provided how to accomplish this.</description><pubDate>Mon, 16 Apr 2007 18:08:46 GMT</pubDate><dc:creator>Rav</dc:creator></item><item><title>RE: Controls not readonly when bound to a businessbindingsource</title><link>http://forum.strataframe.net/FindPost8136.aspx</link><description>All of your 3 points really come down to one anwser.&amp;nbsp; The logic that enables and disables fields based on their editing state is actually in the controls rather than the BO.&amp;nbsp; StrataFrame comes with an interface called IBusinessBindable which is the interface that provides native data binding.&amp;nbsp; This interface also has the method hooks that provide the enabled and disabled&amp;nbsp;status of the controls based on the state of the BO.&amp;nbsp; So you would have to do one of two things:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You could create a custom grid text box that implements the IBusinessBindable interface and add your enabled and disabled logic.&lt;/LI&gt;&lt;LI&gt;You could simply use the raised events on the BO to enabled or disabled the fields within the grid.&amp;nbsp; For example, you could manage the EditingStateChanged event of the BO and set the fields accordingly.&lt;/LI&gt;&lt;/OL&gt;</description><pubDate>Mon, 16 Apr 2007 09:51:48 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>