[RESOLVED] Application Settings Bind to Variable
hi guys! help please...how can i bind the application settings to a variable..currently i have the code below which bind the value to a property of the control in that case the .Text Property of the TxtSettingsStartLocation Textbox.
Code:
private Application_Settings AppSettings = new Application_Settings();
Binding Binding_Start_Location = new Binding("Text", AppSettings, "Start_Location", true, DataSourceUpdateMode.OnPropertyChanged);
txtSettingsStartLocation.DataBindings.Add(Binding_Start_Location);
sealed class Application_Settings : ApplicationSettingsBase
{
[UserScopedSetting()]
public string Start_Location
{
get { return (string)this["Start_Location"]; }
set { this["Start_Location"] = value; }
}
}
Thanks in advance!
Re: Application Settings Bind to Variable
Oh! i got it...this is what I did..
Code:
String CurrentLocation;
string NewStartLocation = "My new location"
CurrentLocation = AppSettings.Start_Location;
AppSettings.Start_Location = NewStartLocation
anyway....any good suggestion than that?
Re: Application Settings Bind to Variable
There's no such thing as binding to a variable. The data-binding mechanism requires the use of properties. You can simply assign a value from a setting to a variable and back again, but the .NET data-binding mechanism requires a property. That's because properties are actually methods internally and thus can do much more than a simple assignment, which is all you can do with a variable.
Re: Application Settings Bind to Variable
Oh I see....Thanks for the Info JM..