VB.NET - Adding Custom User Control to a form at runtime
Posted on 2006-04-14
I have a main form that contains a ListView of user control names, i.e., Mortgage, Note, Arm, Application, etc.... These names correspond to a custom user control that I created.
I have another form called frmWorkspace. Depending on what 'module' the user chooses from the ListView, I want to load/add the corresponding custom user control to frmWorkspace. Therefore, if the user selects 'Mortgage' from the list, any previously added control will be removed, and the 'Mortgage' custom control will be added to frmWorkspace.
I would imagine that this should occur on the 'SelectedIndexChanged' event of the ListView. I have tried many version of the following code to no avail:
Dim ctlMortgage As New Mortgage
I have searched EE but I could not find examples of dynamically adding/removing USER controls at runtime.
Any help would be greatly appreciated....