Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI app, forms, xml 2

Status
Not open for further replies.

wASP

Programmer
Jun 28, 2001
23
0
0
ZA
i have an MDI application, which reads child forms from seperated form classes, each built into their own dll which i just reference.

I now want to make this more dynamic by having an XML file which will determine the sequence / flow of the forms to be opened, and thus a SUB which will take the reference to the project and its formname and open the form within the MDI parent window.

eg.
<forms>
<form id=1>
<formname>frmAbout</formname>
<projref>About</projref>
<cls>about.ddl</cls>
</form>
<form id=2>
<formname>frmLegal</formname>
<projref>Legal</projref>
<cls>legal.ddl</cls>
</form>
<form id=3>
<formname>frmForm1</formname>
<projref>Form1</projref>
<cls>form1.ddl</cls>
</form>
<form id=4>
<formname>frmForm2</formname>
<projref>Form2</projref>
<cls>form2.ddl</cls>
</form>
</forms>

Public Sub OpenChildForm(ByVal id as Integer)

'' Determine class name, dll, and project reference

***** THIS IS WHERE I GET STUCK
***** HOWTO REFERENCE A CLASS BY A STRING VALUE ???

Dim ChildForm As New projref.formname '*** derived from XML
ChildForm.MdiParent = Me
ChildForm.Show()
End Sub

>:):O> wASP >:):O>
 
Hi
To open a form by its name here is the Code
'Say if you waan open Form2 which resides in WindowsApplication6

TextBox1.Text = &quot;WindowsApplication6.Form2&quot;
Try
Dim tempAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
' if class is located in another DLL or EXE, use something like
' tempAssembly = Assembly.LoadFrom(&quot;myDLL.DLL&quot;)
' or
' tempAssembly = Assembly.LoadFrom(&quot;myEXE.exe&quot;)

Dim frm1 As Form = CType(tempAssembly.CreateInstance(TextBox1.Text), Form) ' as Form;
frm1.Show()

Catch ex As Exception

MessageBox.Show(&quot;Error creating: &quot; + ex.ToString())

End Try

Regards
Nouman

Nouman Zaheer
Software Engineer
MSR
 
Brillaint, this really helps alot. Thanks for your help, your knowledge is surely appreciated.

>:):O> wASP >:):O>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top