WinForm multiple forms, menus, and toolbars

Source: Internet
Author: User

Today, I first learned about the WinForm program development often encountered problems-multi-form program running problems.

When developing a multi-form program, you often encounter the following four issues:

First, which is the main form

Problem: The main form is hidden, and after closing other forms, the main form is not displayed/closed, then the program is closed.

When this problem is encountered, our usual workaround is to pass the value of the constructor, and then transfer the form to another form to close it.

Second, the form can only open a

Creates a global generic collection in order to place all open forms. Before the form opens, determine if there is a name-consistent form in the collection, and if it is already open, do not open it again.

Issue: When the form is open, it cannot be opened again after it has been closed.

The usual workaround for this problem is to clear the Form object record in the collection in Form1 when the form is closed.

Issue: When the form is already open, clicking the Open button again will not re-display the open form and focus into.

The solution to this problem is to find the open object, set the WindowState property to: Formwindowstate.normal; Find the object that has the open form, and use the focus method.

Third, the transfer of value and control between the form

Pass value: The value of the constructor.

Control: The first step, locate the Form object, and the second step, change the control value of the Form object.

  Note: To modify the access permissions for objects in the form.

  Iv. form of the type of the prompt box

ShowDialog ();

It does this by popping up a form that has to enter the contents of this form before it can continue with other forms.

Next, I learned the contents of menus and toolbars. 

1, MenuStrip:
Top Menu
Split Line: 1,-2, right-click to insert Split ...

Shortcut keys: Each item right-click the bottom of the property to set shortcut keys
Shortcut keys work regardless of whether the option is hidden or the menu is hidden

2, ContextMenuStrip:
Right-click menu

3, Statusstript:
Bottom Menu

4, ToolStrip
Tool bar

5, ToolStripContainer
Tool Bar Container

WinForm multiple forms, menus, and toolbars

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.