Trying a simple project to create my own (very basic) data binding.
I have a class FIELD_DESCRIPTOR which stores meta information about a database column. There will be a further class FIELD which represents the actual field, which will contain a reference to its corresponding FIELD_DESCRIPTOR class.
I am getting stuck in 2 places.
First, I need to have a property in the FIELD_DESCRIPTOR class that stores what kind of Windows Forms control the field is mapped to at the front end. for e.g. I need a property, say, MAPPED_CONTROL_TYPE. And I should be able to store either TextBox, ComboBox etc in this property. Should I just use a string property and be done with it ? Or is there a better way ? Ideally, I’d like to use some kind of enumeration of control types.
Secondly, I need to store a reference / handle to the actual control the field it mapped to. (I think I can do this by passing a reference of the actual control on the form.)
How do I implement this ? What kind of dataType should be used to define this property ?
(Using .Net 3.5, No WPF)
Thanks and regards.
The fully qualified type name springs to mind, e.g. System.Windows.Forms.TextBox. This should be unique, and could always be used for dynamic creation if needed.
You could indeed store the reference using a type such as System.Windows.Forms.Control. If you do, be carefult that you don’t create a memory leak. i.e. When you control is no longer needed, you should no longer hold its reference in your lookup otherwise you will stop it being disposed.