Obtain and modify attributes of the parent form of the MDI child form in VB.net

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.