MDI help

mistaken_myst

Active member
Joined
Oct 29, 2007
Messages
25
Programming Experience
Beginner
Hello, I need help on MDI use.

Forms: frmCon, frmF1, frmF2, frmF3, frmF4, etc ..

Most of the Forms creation below is activated using Buttons:

From frmCon (Container):
dim f1 as frmF1
f1.mdiParent = Me
f1.Show()
From frmF1:
dim f2 as frmF2
f2.mdiParent = frmCon.ActiveForm
f2.Show()
From frmF2:
dim f3 as frmF3
f3.mdiParent = frmCon.ActiveForm
f3.Show()
From frmF3:
dim f4 as frmF4
f4.mdiParent = frmCon.ActiveForm
f4.Show()

1. If frmF1 Button is pressed twice, 2 frmF3 will be opened.. How can I verify that an instance of frmF3 is already opened before opening a new frmF3 ?

2. I'm quite new at MDI use, please tell me if there things I should improve in the way I'm using it.
 
put this code in the click event handler
VB.NET:
if omyForm IsNot Nothing and not myForm.disposing then
    omyform.activate
    omyform.bringtofront
else
    omyform=new myForm
end if

omyForm.show
 
Your code does not work - I dont' understand it well..

Is myForm : frmF2? & onmyForm has not been declared yet in the 1st line.. 'IsNot' is not recognized as a Keyword..

if omyForm IsNot Nothing and not myForm.disposing then
omyform.activate
omyform.bringtofront
else
omyform=new myForm
end if
omyform.mdiParent = frmCon.ActiveForm
omyForm.show
 
you're right... the disposing property need to be replaced by IsDisposing property

VB.NET:
Public Class Form1
    Dim f As New Form2
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If f IsNot Nothing And Not f.IsDisposed Then
            f.Activate()
            f.BringToFront()
        Else
            f = New Form2
            'f.MdiParent = me
        End If
        f.Show()
    End Sub
End Class

isnot is an valid operator.
declare your form object with global scope, is totally necessary
 
Last edited by a moderator:
Back
Top