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
- Create a New Visual C # windows application. By default, Form 1 is created.
- Click form, and thenViewChooseProperty WindowTo view the form attributes.
- SetBackground ColorSet Properties as needed (for exampleLightblue) Color.
- SetIsmdicontainerSet propertyTrue. Note that the background color of the form is changed to control panel.Application back-to-backThe color of the landscape.
- SetWindowstateSet propertyMaximized.
- Double-click the form to view itsCodeWindow.
- 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 ();