Posted 19 years ago
by ktaite
If I use reflection to call a method which creates a new document window, I don't receive any exceptions but the tabbed document window is not displayed. If call the method directly then the document window is displayed. UIStudio 2.0
See attached code snippet
Sample code
//create a new document
public void CreateTabWindow(string uc, string CaptionName)
{
UserControl uCtrl = null;
try
{
if (uc == "chart") uCtrl = new UnfChart.ctrGigChart();
// Create the document
ActiproSoftware.UIStudio.Dock.DocumentWindow dw = new ActiproSoftware.UIStudio.Dock.DocumentWindow(dockManager1, CaptionName, CaptionName, null, uCtrl);
dw.Activate();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//if I call this mehtod directly this works
public void OpenNewDocWindow()
{
CreateTabWindow("chart", "trend");
}
//If I call the method the document window does not get displayed
private void UseRef()
{
MethodInfo mi;
object result = null;
try
{
Type otype = this.GetType();
mi = otype.GetMethod("OpenNewDocWindow");
if (mi != null)
{
string typeName = otype.FullName;
object lateBoundObj = Activator.CreateInstance(otype);
result = otype.InvokeMember("OpenNewDocWindow", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, lateBoundObj, null);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Thanks
See attached code snippet
Sample code
//create a new document
public void CreateTabWindow(string uc, string CaptionName)
{
UserControl uCtrl = null;
try
{
if (uc == "chart") uCtrl = new UnfChart.ctrGigChart();
// Create the document
ActiproSoftware.UIStudio.Dock.DocumentWindow dw = new ActiproSoftware.UIStudio.Dock.DocumentWindow(dockManager1, CaptionName, CaptionName, null, uCtrl);
dw.Activate();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//if I call this mehtod directly this works
public void OpenNewDocWindow()
{
CreateTabWindow("chart", "trend");
}
//If I call the method the document window does not get displayed
private void UseRef()
{
MethodInfo mi;
object result = null;
try
{
Type otype = this.GetType();
mi = otype.GetMethod("OpenNewDocWindow");
if (mi != null)
{
string typeName = otype.FullName;
object lateBoundObj = Activator.CreateInstance(otype);
result = otype.InvokeMember("OpenNewDocWindow", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, lateBoundObj, null);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Thanks