ApplicationSettings property binding in TextBox with integer value
-
How to relate TextBox.Text field with integer value in application settings? If e.g. Settings.Default.MyValue is not a string it is not possible to assign it to controls returning string in applicationsettings property binding property.
Чесноков
-
How to relate TextBox.Text field with integer value in application settings? If e.g. Settings.Default.MyValue is not a string it is not possible to assign it to controls returning string in applicationsettings property binding property.
Чесноков
With Windows Forms? The conversion should be done implicitly... This works on an integer app setting called "MyAppSetting"...
private void On\_FormLoad(object sender, EventArgs e) { Binding binding = new Binding("Text", MyAppNamespace.Properties.Settings.Default, "MyAppSetting", true, DataSourceUpdateMode.OnPropertyChanged); this.textBox1.DataBindings.Add(binding); }
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Thursday, May 12, 2011 2:00 PM
-
With Windows Forms? The conversion should be done implicitly... This works on an integer app setting called "MyAppSetting"...
private void On\_FormLoad(object sender, EventArgs e) { Binding binding = new Binding("Text", MyAppNamespace.Properties.Settings.Default, "MyAppSetting", true, DataSourceUpdateMode.OnPropertyChanged); this.textBox1.DataBindings.Add(binding); }
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Thursday, May 12, 2011 2:00 PM
Yes, in windows forms. I have int MyAppSetting in application settings defined. It is not possible to set it in ApplicationSettings property binding for TextBox.Text property. Only if MyAppSetting is a string that can be setup in the IDE and I have to query it as
Int32.Parse(MyAppNamespace.Properties.Settings.Default.MyAppSetting)
. Did you mean explicitly? The only solution to add the logic in code?Чесноков
-
Yes, in windows forms. I have int MyAppSetting in application settings defined. It is not possible to set it in ApplicationSettings property binding for TextBox.Text property. Only if MyAppSetting is a string that can be setup in the IDE and I have to query it as
Int32.Parse(MyAppNamespace.Properties.Settings.Default.MyAppSetting)
. Did you mean explicitly? The only solution to add the logic in code?Чесноков
I'm not a forms programmer, but I see that using the VS10 designer properties window to add the binding adds a line of code that initializes the textbox.Text property, and that line won't compile. Funny it doesn't even need that line...bug or feature? So it looks to me like the binding needs to be added by hand, which I tested and it works fine.
Mark Salsbery Microsoft MVP - Visual C++ :java: