.NET Framework - Dynamically load custom controls

Asked By Maanu
12-Mar-10 11:48 AM
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!
CtrlType.Assembly.CreateInstance
(1)
CtrlType.FullName
(1)
Combobox.SelectedIndex
(1)
Type.GetType
(1)
ComboBox
(1)
SelectedIndexChanged
(1)
CreateInstance
(1)
SelectedIndexChange
(1)
  amdrit replied to Maanu
12-Mar-10 11:53 AM
A quick google found:  http://ilab.ahemm.org/DynamicControls.html
  Mr. Arnold replied to Maanu
12-Mar-10 12:03 PM
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.
}
  zooots replied to Maanu
12-Mar-10 12:43 PM
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
Create New Account
help
Data Bound Combobox SelectedIndex .NET Framework Good evening, I have a form with a data bound combobox and would item into the combobox at position 0: ComboBox.Items.Insert(0, "") -Scott keywords: Data, Bound, Combobox, SelectedIndex description: Good evening, I have a form with a data bound combobox and would for
ComboBox SelectedIndex nicht blau markiert .NET Framework Hallo NG, kleine Frage. Beim Füllen und Selektieren des ersten Handle durchführen. ciao Frank - - Dipl.Inf. Frank Dzaebel [MCP / MVP C#] http: / / Dzaebel.NET keywords: ComboBox, SelectedIndex, nicht, blau, markiert description: Hallo NG, kleine Frage. Beim Füllen und Selektieren des ersten Items
Setting combobox selectedindex .NET Framework Hi, I have a combobox that when I set the SelectedIndex to -1 or SelectedIndex -1 is going to make the event firer and execute code? keywords: Setting, combobox, selectedindex description: Hi, I have a combobox that when I set the SelectedIndex to -1 it