I'm creating a capture form on the fly based on a set of metadata held in a EAV type schema.
My trouble is in load the data back to the control, and in particular a winforms combobox.
Also using Entity Framework for the data that is bound to the control.
Check is control exist, else create. for each mapped property set their values. i.e. Datasource, DisplayMember, ValueMember, etc...
Load value is exists to SelectedValue property? this is where is fails?
On inspection of the object it seems as if none of the previous values including the datasource has been loaded yet? But the combobox does show the values once rendered?
Here are some snippets of the code.
Type oType = Type.GetType("System.Windows.Forms.ComboBox");
if (oControlObject == null)
{
oControlObject = (Control)Activator.CreateInstance(oType);
oControlObject.Tag = item;
oControlObject.CreateControl();
}
...Loop to set Datasource, DisplayMember & ValueMember ...
if (property.IsReadProperty.Value && value != null)
{
PropertyInfo propSet = oType.GetProperty(property.PropertyName); //PropertyName here is "SelectedValue"
propSet.SetValue(oControlObject, value.Value, null);
}