Dynamically load custom controls

  • Thread starter Thread starter Maanu
  • Start date Start date
M

Maanu

Hi,

When the user selects an item in a combo box, I need to load the
corresponding custom control on a particular area of the form. There can be n
items in the combo box. The association between an item in the combo box and
the corresponding custom control will be kept in an xml file.

Is that possible?

What would be the steps involved in loading custom controls in this way?
Where can I get more information?

Thanks!
 
Maanu said:
Hi,

When the user selects an item in a combo box, I need to load the
corresponding custom control on a particular area of the form. There can be n
items in the combo box. The association between an item in the combo box and
the corresponding custom control will be kept in an xml file.

Is that possible?

What would be the steps involved in loading custom controls in this way?
Where can I get more information?

Combox_SelectedIndexChanged()
{
It would be the event to find out what was selected in the combobox by
the user.
Assuming that combobox was loaded with combox.DataValue (a key) or
getting the Combobox.SelectedIndex what item in the Combox was selected will
allow you to call this other control with information about the selction.

You're other control can be accessed in this method.

You can also get the combobox.text here too of the item selected.
}
 
ComboBox_SelectedIndexChange(object sender,EventArg e)
{
ComboBox combo = (ComboBox)sender;
string CtrlTypeName = combo.SelectedValue;
Type CtrlType = Type.GetType(CtrlTypeName);
object ctrl = CtrlType.Assembly.CreateInstance(CtrlType.FullName);
InitialCustomerCtrl;
Panel.Controls.Add(ctrl);
}

zooots
 
Back
Top