Yes, this is the dilema which I am trying to solve whether with the above code or from the code at the top of this thread. Basically I need to know the .net syntax to have the Type.GetType() get the type of the control which is represented by the string LcClassName which in the sample above would be "ListReportControl". ListReportControl is a control. One of about 600 report controls. Each control represents a Sharpshooter report. Initially all the Reports are in SQL, then loaded into a TreeView on the left side of a "viewer" form. The user selects a report such as one "ListReportControl". I then need to instantiate that control into a "commonControl" for the global report viewer which appears in a host panel to the right of the treeview. Other than the treeview which comes from a SQL table, I do not want to hardcode all 600 possible report controls into code. Hence when the user clicks a report in the treeview, after the treeView_AfterSelect event is triggered. At that point I have a string value (LcClassName) which has the name of the report control such as "ListReportControl".
Basically inserting this code works perfect with the issue that the Report Name control "ListReportControl" is coded to make it work. I believe there is a way with "reflection" to allow me to specify a string such as LcClassName and the code would then take the "value" of the string and return the "type" of value of the string which is "ListReportControl".
Control
Text =
(newSample
activeReportSlot = (newSample
RenderReport();
newSample.Dock =
c = hostPanel.Controls[0];
{
hostPanel.Controls.Remove(c);
hostPanel.Controls.Add(newSample);
}
I think the problem is that you´re asking to create an instance of type string as described bellow
Dim loObject As ObjectDim loType As Type '-- Get the type loType = Type.GetType(LcClassName)
'-- Create the object loObject = Activator.CreateInstance(loType)
Paul
string strReportName = "ListReportControl";
Control newSample = (Control)Activator.CreateInstance(typeof(ListReportControl));