c# - Updating bound controls to ApplicationSettings -
I am trying to use the .NET 2.0 application settings for the first time, and a little searching for it ... Puzzling in some ways I am hoping someone can help me explain why I am wrong.
I have a generic settings class that I have implemented that application sub-class of the settingsbase. I have applied a property, and tagged it. It starts to work
I have tried to force a list box for the property, and it also works. When I open the form, it loads the property properly.
The problem I am running is that if I want to update settings and databases without reloading the format, then this does not work. There is no method for refreshing the binding, and what I am reading should only be updated automatically (applying the Appattingbase IPPro Change Notifail, which should subscribe to databases .. but this is not working) . If you have databanking, you can not manually list.
Here's my code:
Settings.cs
Public class settings: ApplicationSettingsBase {public settings () {if (fixed book == empty ) Fixedbook = new list & lt; String & gt; (); } [UserScopedSetting ()] Public listing & lt; String & gt; Fixedbook ({return (list & lt; string & gt;) this ["fixed-book"];} protected set {This ["fixed-book"] = value;}}}
SettingsForm Cs
settings _settings = new settings (private) SettingsForm_Load (object sender, eventErgus E) {lbFixedColumns.DataBindings.Add (new binding ("data source", _ settings, "fixedbook" , False, datasosupdated.edirectory.php);} Private Zero DoSomething () {_settings.FixedBooks.Add ("Test");}
I understand that appSettings can add something IPPriti Chengalated Notification should be warned to force the control that the property has changed, and it has been forced to reload it. But it does not seem like this
What do I remember Coming?
Edit:
I believe I know what the problem is. The problem is that I am changing the contents of the collection in the settings category , But do not change the actual property I have been there (which is the collection). I think that I really have to add or remove the entire collection to bring the Ipotate Change Notifier to the fire, it is not happening.
I'm not sure what the solution to this problem is.
You need to save the setting and reload it:
< Code> Private Zero DoSomething () {_settings.FixedBooks.Add ("Test"); _settings.Save (); _settings.Reload (); }
I agree with your edit and your comments. Try using a binding list instead.
Example:
Public class settings: application settingsbase {public settings} (if (fixed book == zero) fixedbook = new binding list (); Fixed IBook.ListChanged + = fixed IBooks_ListChanged;} zero fixedbox (object sender, list changed event events e) {this ["fixedbook"] = fixedbook;} [UserScopedSetting ()] public binding list & lt; string & gt; ; Fixedbook ({returns (binding lis) Click on this ["Fixed book"];} Protected Set {This ["FixedBook"] = Value;}}}
Comments
Post a Comment