2
Answers

Connect object property values to a form control

Ask a question
Keith Mathews

Keith Mathews

14y
2.5k
1

First - yes I'm very new to C#, .net, and the rest of this object oriented stuff.  I did a decent amount of stuff under old ANSI-C...
I'd like to include some controls in a GroupBox as part of my class.  I probably could just make sure I always handle changes in data values and update the controls, I can demonstrate that this works. 
I also know that there is a concept of "data-binding", and have built some small Access databases and bound them to DataGridView controls successfully.
What I'd like to do is bind the value of the class.property to the class.control.value so that the two are always synchronized.  Is that possible? What keywords should I be searching under?  I hate just "asking" for help, but any direction would be very helpful.
One thought I'm having even as I type this - Can I just make the control.value the effective storage for the class.property value?  I could create appropriate {get; set;} methods that work directly on the control.  Would this be considered "good-practice"?  or is there some better practice I should learn?
Again, thanks in advance for any advice.

Answers (2)