当一个FORM窗体把IsMidContainer属性改为TRUE的时候,背景色就变成深灰,怎样改变其背景色.谢谢. [问题点数:50分,结帖人eric88]
收藏关注eric88eric88
本版等级:
结帖率:100%
楼主 发表于: 2006-10-19 15:20:50
RT
更多 分享到:
对我有用[0]丢个板砖[0] |
举报 | 管理
回复次数:6
关注tjvictor灰太狼
本版等级:
得分:10 回复于: 2006-10-19 15:29:29
private System.Windows.Forms.MdiClient MyClient = null;
foreach(System.Windows.Forms.Control myControl in this.Controls)
{
if(myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
{
MyClient = (System.Windows.Forms.MdiClient)myControl;
break;
}
}
if ( MyClient != null )
MyClient.BackgroundImage = Image.FromFile( "aaa.gif" ) ;
对我有用[0]丢个板砖[0] |
举报 | 管理
关注eric88eric88
本版等级:
得分:0 回复于: 2006-10-19 15:39:52
已经解决.
我的方法是在FORM上加了一个panel填充到整个FORM让panel当背景.就可以了.
谢谢楼上的.
对我有用[0]丢个板砖[0] |
举报 | 管理
关注gezichonggezichong
本版等级:
得分:10 回复于: 2006-10-19 15:42:35
msdn帮助里面的..
Create a Sample Windows Application by Using Visual C# .NET
Create a new Visual C# .NET Windows application. Form1 is created by default.
Click the form, and then, on the View menu, select Properties Window to view the properties for the form.
Set the BackColor property to the color that you want (such as LightBlue).
Set the IsMDIContainer property to True. Note that the background color of the form changes to the color that the Application Background color is set to in Control Panel.
Set the WindowState property to Maximized.
Double-click the form to view its code window.
Paste the following code into the form's Load event 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();
On the Project menu, click Add Windows Form.
Accept the default name Form2.cs, and then click Open.
Press F5 to run the application.
Note that the MDI parent form loads and has a light blue background.
对我有用[0]丢个板砖[0] |
举报 | 管理
关注eric88eric88
本版等级:
得分:0 回复于: 2006-10-19 15:57:01
TO gezichong(鸽子虫) :
这个方法好.
我把背景色改成下面这个了.就跟C#默认的控件顔色一样.
ctlMDI.BackColor = System.Drawing.SystemColors.Control;
对我有用[0]丢个板砖[0] |
举报 | 管理
关注SOFT_LINSOFT_LIN
本版等级:
得分:10 回复于: 2006-12-14 15:09:44
直接设置子窗体就可以了!
对我有用[0]丢个板砖[0] |
举报 | 管理
关注SOFT_LINSOFT_LIN
本版等级:
得分:20 回复于: 2006-12-14 15:15:56
MdiClient MDclient;
foreach (Control ctl in this.Controls)
{
try
{
MDclient= (MdiClient) ctl;
// 设置MDI窗体的背景色
MDclient.BackColor = System.Drawing.SystemColors.Control;
}
catch
{
}
}