怎么设置父窗体的背景图片啊?
是这样吗
MdiClient m = new MdiClient();
this.Controls.Add(m);
m.BackgroundImage = Image.FromFile("img.jpg");还是这个样子
?
foreach (System.Windows.Forms.Control myControl in this.Controls)
{
if (myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
{
bgMDIClient = (System.Windows.Forms.MdiClient)myControl;
break;
}
}
bgMDIClient.BackgroundImage = Image.FromFile("img.jpg");为什么我的子窗体show后看不到呢 感觉在图片后面是的
谁能告诉我这是怎么回事 在线等
是这样吗
MdiClient m = new MdiClient();
this.Controls.Add(m);
m.BackgroundImage = Image.FromFile("img.jpg");还是这个样子
?
foreach (System.Windows.Forms.Control myControl in this.Controls)
{
if (myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
{
bgMDIClient = (System.Windows.Forms.MdiClient)myControl;
break;
}
}
bgMDIClient.BackgroundImage = Image.FromFile("img.jpg");为什么我的子窗体show后看不到呢 感觉在图片后面是的
谁能告诉我这是怎么回事 在线等
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "图片|*.jpg;*.bmp;*.png||";
if (dlg.ShowDialog() != DialogResult.OK) return;
foreach (Control c in this.Controls)
{
if (c is MdiClient)
{
c.BackgroundImage = Image.FromFile(dlg.FileName);
}
}
}
子窗体的背景图片可以看到,只要窗体上没有被其它控件完全遮盖。
foreach (System.Windows.Forms.Control myControl in this.Controls)
{
if (myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
{
bgMDIClient = (System.Windows.Forms.MdiClient)myControl;
break; <-- 这里多余,这样只能设置一个子窗体的背景
}
}
bgMDIClient.BackgroundImage = Image.FromFile("img.jpg"); <-- 这个应挪到循环里