Dynamic form loading...Help pls..

  • Thread starter Thread starter Sachi
  • Start date Start date
S

Sachi

Hi,
I saw your article in msdn about loading forms
dynamically. It is really a great article.
URL: http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet10082002.asp

Sorry, soo far i never had tried anything with
winforms..was working much with webforms.

Currently as we are moving into winforms, I am looking
for better ways to load the forms from the MDI.
You way of explain is really good. But the problem is i
stuck with basics.

Question : You are loading form based on the combo box
selected value.
My requirement is either when user click on menu
item or on tool bar item, i need to load the form.
How this can be acheived?

Hope to get your reply sooner.

Thanks and Regards,
Sachi
 
Put something like this in Menu click event handler or
create a separate function in MDI parent.
If you wish only one form to be available at any time
use this:

Sub xxx()
Dim o As Form
For Each o In Me.MdiClidren
If TypeOf(o) Is YourChildFormClassName Then
o.Activate
Exit sub
Next o
o = New YourChildFormClassName()
o.MdiParent = Me
o.Show
End Sub

Omit the For Each...Next loop if you don't care how
many child forms of the same type may be opened.

Ralfs
 
Back
Top