Dynamically load custom controls

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!
 
M

Mr. Arnold

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.
}
 
Z

zooots

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top