i am new to VB.Net. I have an assignment to submit next week that is on the 5 november 2007, and am having some problem in creating my program. Can you please help?

i want to limit my MDI to open only one specific form at a time. like for example if the menu balance is selected from the mdi, it must display a form and the menu in the mdi mus be disable.
Here is the code used, the only thing is that i do not know how to make the button enable again once the form is closed.


Public Class Bank_Account
Inherits System.Windows.Forms.Form
Dim View_Balance As Integer = 0
Dim childForms(1) As Balance


Private Sub mnuBalance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBalance.Click

View_Balance += 1
childForms(View_Balance) = New Balance
childForms(View_Balance).Text = "ChildForm" & Str(View_Balance)

'setting title for child windows and incrementing the number with an array
childForms(View_Balance).MdiParent = Me
childForms(View_Balance).Show()
mnuBalance.Visible = False

End Sub

please do answer me because i really don't know what to do anymore.

i wanted to use an if condition to do the above by the click of the button but i do not know how. please help.

my regards,

Try enabling the menu on

Private Sub frmMDIChild_FormClosing(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
               'Enable Menu Here
 
 
End Sub

Where am i suppose to place the code?? Because when i paste it in my MDI form, the

System.Windows.Forms.FormClosingEventArgs(it says not define)
and

Me.FormClosing(Ketword not valid as an identifier)
are underline...

what am i suppose to do???

Where am i suppose to place the code?? Because when i paste it in my MDI form, the

System.Windows.Forms.FormClosingEventArgs(it says not define)
and

Me.FormClosing(Ketword not valid as an identifier)
are underline...

what am i suppose to do???

You should put the code in the form closing event for the View_Balance form.

Private Sub View_Balance _FormClosing(ByVal sender As Object, _

ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing'Enable Menu HereBank_Account.mnuBalance.enabled= TrueEnd Sub

thx a lot for replying...ok i think i understand.
I double clicked on my Balance form which is the child, and i changed its declaration as closing...I got the abouve result, but the thing is that frmBank_Account.mnuBalance.enabled=true is not working...
do i need to create a module smething like that???

Which version of vb.net are you using? The code I posted works with the 2005 one.

You will have to add a module to your project and then declare a public variable inside your module as menuitem. After that, in the parent form's activated event, set the varialbe you declared in the module equal to mnuBalance. In the closing event for the View_Balance form, enable the module level variable. I'll include the code below to help out.

The module code:

OptionStrictOn
 
Module mVariables
 
  Public mBalance As MenuItem
 
EndModule

The code in the form activated event for Bank_Account:

PrivateSubBank_Account_Activated(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMyBase.Activated
 
 mBalance= mnuBalance
 
End sub

The code in the from closing event for View_Balance:

PrivateSub View_Balance_Closing(ByVal sender AsObject, ByVal e As System.ComponentModel.CancelEventArgs) HandlesMyBase.Closing
 
 mBalance.Enabled = True
 
End sub

I thank u very much for your help. it works perfectly...
i have one more question to ask...
Suppose i have 4 forms, 1st one is frmMainProg which is an IsMDIContainer, once mnulogin is selected, the 2nd form which is frmlogin appears and once login, frmBank_Account appears(also acts as IsMDIContainer)and finally once frmbalance is selected from frmBank_Account, rmBalance appears. the problem is that the frmBank_Account cannot be both mdichildren and mdiparent at the same time. Is there any solution for this????

I have a procedure that does this

Public Sub ShowForm(ByVal FrmSwitch As FrmToShow)

Select Case FrmSwitch

Case Is = FrmToShow.FrmRecommendAssignment
If _FrmRecommendAssignment = 1 Then
ChildForm8.FindForm()
Else
ChildForm8 = New FrmRecommendAssignment
ChildForm8.Visible = True
ChildForm8.MdiParent = Me
ChildForm8.StartPosition = FormStartPosition.CenterScreen
ChildForm8.Show()
_FrmRecommendAssignment += 1
End If
end select

thx 2 you all for your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.