I have developed a generic TreeList control in C# which combines a TreeView with a ListView to obtain a multi-column TreeView.
I would like to use a TreeView derived class for the TreeView portion of the control, but keep the TreeListView control generic.
In my TreeListView I have a member variable:
protected TreeView treeView;
and the InitializeComponent function creates the treeView:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.listView = new System.Windows.Forms.ListView();
this.treeView = new System.Windows.Forms.TreeView();
So if I have a derived TreeView class called MyTreeView, is there any way in which I could get InitializeComponent to do something like:
this.treeView = new MyTreeView()
but somehow specifying the type of class to instantiate at runtime, e.g. this.treeView = new (typeof(
type specified in constructor)
?