0 recommended After several years of Web Front-end development, we often use the f r a m e s e t framework to create an HTML file and divide the page into four parts: head, content, main, and foot, and then point to four separate HTML files. Head is a banner at the top, and content is the menu on the left. Most of them are made using the tree control. In the middle, main is the main page to be displayed. Then, you can click content on the left, switch between different home pages. As shown in: Recently, due to work requirements, I plan to develop a winform program in C #, and hope to implement the effect of F R A m e s e t similar to web in winform, after research, we have summarized a simple solution with the following results: The specific method is as follows: first create a "Windows application", first Delete the default "form1" file, and then create a form called mainform as the main form of the program. Drag three widgets from the control box: menustrip, toolstrip, and statusstrip. Note that you should change the Dock of toolstrip to left, which is similar to the content of f r a m e.Set "ismdicontainer" of mainform to "true", which means it can accommodate multiple form objects. Below we can create a batch of forms, similar to the web program to create a batch of aspx files, each form implements different functions. These form "formborderstyle" must be set to none, so that the buttons to maximize and minimize will be hidden. In addition, set autosize to true to enable the form to adapt the size of the main form. Set "showintaskbar" to false. In the load events of these child forms, add a function and write the following sentence: This. Dock = dockstyle. Fill; This is to fill the main form. Next, add some buttons in the toolstrip control of the main form, and then write the functions for clicking these buttons. In the function, you first need to generate the child form instance, and then add a key sentence: Form_child.mdiparent = this; This sentenceCodeIt means that the mainform contains this subform. When you add multiple buttons in toolstrip, You need to determine if the corresponding child form has an instance when clicking the button. If yes, use form_child.activate () the child form is displayed. Then, we need to write some public functions in the mainform class so that the subform can control the statusstrip of the mainform and display some status information. In addition, in the development of winform programs, if a function runs for a particularly long time, it must be called using a delegate method. Otherwise, a button is clicked, form loses its response and is blocked. For the use of delegation, we willArticle. |