In winform of C #, the MDI parent form changes the background color.

Source: Internet
Author: User
ArticleDirectory
    • Use Visual C #. Net to create a sample Windows Application
When you use a Windows form as an MDI parent form Backgroundcolor Attribute, ApplicationProgramBackground Color settings determine the background color of the form. The following steps demonstrate how to programmatically change the background color of the MDI parent form to another color. Use Visual C #. Net to create a sample Windows Application
    1. Create a New Visual C # windows application. By default, Form 1 is created.
    2. Click form, and thenViewChooseProperty WindowTo view the form attributes.
    3. SetBackground ColorSet Properties as needed (for exampleLightblue) Color.
    4. SetIsmdicontainerSet propertyTrue. Note that the background color of the form is changed to control panel.Application back-to-backThe color of the landscape.
    5. SetWindowstateSet propertyMaximized.
    6. Double-click the form to view itsCodeWindow.
    7. Paste the following code toLoadEvent Handler:

 

Mdiclient ctlmdi; // loop through all of the form's controls looking // for the control of Type mdiclient. foreach (control CTL in this. controls) {try {// attempt to cast the control to type mdiclient. ctlmdi = (mdiclient) CTL; // set the backcolor of the mdiclient control. ctlmdi. backcolor = This. backcolor;} catch (invalidcastexception exc) {// catch and ignore the error if casting failed .}} // display a child form to show this is still an MDI application. form2 FRM = new form2 (); frm. mdiparent = This; frm. show ();

 

 

 

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.