My brother started the project a few days ago and used vb.net for the first time. I believe that many beginners will encounter these problems more or less. For the convenience of learning for beginners, I have summarized some small experiences for your reference and discussion.
Article 1: How to control attributes of the parent form in the MDI child form
Function: for example, after opening a child form, you must set a menu item or button in the parent form to invisible, and so on.
Content:
The MDI parent form and MDI child form class are defined as follows:
MDI parent form:
Class MDIForm
Inherits System. Windows. Forms. Form
.........
'Member mnuMain
Friend WithEvents mnuEditPaste As System. Windows. Forms. MenuItem
.......
'Member
Friend WithEvents toolScan As System. Windows. Forms. ToolBarButton
Private sub showChild ()
Dim frmTmp as new MDIChildFom 'define a new instantce of MDIChildForm
FrmTmp. MdiParent = me 'set the new form to be a Mdichild
FrmTmp. show () 'Show the new form
End sub
End Class
MDI child form:
Class MDIChildForm
.......
'Set mnueditpaste & toolscan cannot be seen
Private sub setmdimnutoolunvisible ()
'***************************************'
'First method you can set a menuitem to be unvisable'
'***************************************'
'This method you cocould not control one menuitem
'You can only set a group of menuitems
Me. mdiparent. Menu. menuitems (0). Visible = false 'set the first group menuitem can not be seen
'With this method you have not right to modify toolscan
Dim frmmdi as mdiform
If tyhpeof me. mdiparent is mdiform
Frmmdi = directcast (Me. mdiparent, mdiform) 'Get the instantce of me. mdiparent
'Then you should access all the members of class mdiform without private members
Frmmdi. mnueditpaste = false
FrmMdi. toolScan = Flase
Like this you cocould do everything with MDIForm you want
End if
End sub
End Class