[RESOLVED] [2005] Binding variables to controls
A thought just occured to me. I don't understand what binding's are supposed to handle. Could they be used in such a way that I don't need to set my background variables to be equal to whats displayed in a control manually?
What I mean is: can I use bindings to automatically set the value of one of my variables to the value of a control (eg mystring = TextBox1.Text, except automatically)?
Re: [2005] Binding variables to controls
Yes you can do that if your mystring is a bindable object. Most controls can bind to objects or data although objects may need to implement certain binding interfaces to work right.
Re: [2005] Binding variables to controls
So if I had a NumericUpDown box I wanted to bind to a single or an integer, or a TextBox I wanted to bind to a string, would that work?
Re: [2005] Binding variables to controls
That's EXACTLY what data-binding is. You bind the value(s) in a data store to a value displayed in a control. You can fine tune the behaviour of a Binding in .NET 2.0 but the basic idea is that when you update one the other reflects that change. Probably the most common data-binding is a DataTable to a DataGridView, where any updates the user makes in the grid are automatically propagated to the table. That's called complex data-binding, when you set a DataSource property. Using simple data-binding you can basically bind any property of any control to any suitable object. You should read about the Binding class for more information.
Re: [2005] Binding variables to controls
I suspected that, but that you for stating it clearly for me, jmcilhinney. Thank you too Edneeis. I think I can figure the rest out myself now.