RT
解决方案 »
- webclient 极其诡异的错误。。。
- 给已做好的软件(无源码)加一个一注册码检测的功能。急~~~~~~~
- 关于动态添加tabpage后取值的问题
- C#怎样操作剪贴板
- 关于 SqlParameter 类的一个问题。
- 如何实现CheckedListbox的反选功能?(Winform)
- 请教WinForm的DataGrid中,如何让某个格myRow[xxx]不可编辑,并且显示为空白?
- 关于 CSDN的一个bug,可以看到美女,是不是看到了如下内容呢????(不知道各位都看到的什么???)
- EF5 查询不想用缓存,怎么实现?
- 如何制作 Web安装程序?
- 有没有办法用propertyGrid1控件动态显示XML文档某个结点中的属性?(十万火急)
- 如何用代码实现新建Excel文件和新建xls文件中的表?
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" ) ;
我的方法是在FORM上加了一个panel填充到整个FORM让panel当背景.就可以了.谢谢楼上的.
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.
这个方法好.
我把背景色改成下面这个了.就跟C#默认的控件顔色一样.ctlMDI.BackColor = System.Drawing.SystemColors.Control;
foreach (Control ctl in this.Controls)
{
try
{
MDclient= (MdiClient) ctl; // 设置MDI窗体的背景色 MDclient.BackColor = System.Drawing.SystemColors.Control;
}
catch
{
}
}