子窗口的背景图是加载程序自动读入的
我在MDI容器窗口里
this.size = child.size
获得是子窗口原始的大小,不是读入背景图扩展后的大小
在子容器中有如下代码
Image img = Image.FromFile("pic.JPG");
this.Size = new Size(img.Width, img.Height);
this.BackgroundImage = img;
子窗口的大小可正常随背景图改变。ChildMonitor cMon = new ChildMonitor(this);
cMon.Show();
this.size = child.size在父窗口如上方式初始化,得不到预期结果
我在MDI容器窗口里
this.size = child.size
获得是子窗口原始的大小,不是读入背景图扩展后的大小
在子容器中有如下代码
Image img = Image.FromFile("pic.JPG");
this.Size = new Size(img.Width, img.Height);
this.BackgroundImage = img;
子窗口的大小可正常随背景图改变。ChildMonitor cMon = new ChildMonitor(this);
cMon.Show();
this.size = child.size在父窗口如上方式初始化,得不到预期结果
f.MdiParent = this;
f.FormBorderStyle = FormBorderStyle.None;
f.Show();
this.Size = f.Size;
private void Form2_Load(object sender, EventArgs e)
{
Image img = Image.FromFile("pic.JPG");
this.Size = new Size(img.Width, img.Height);
this.BackgroundImage = img;
}这是我的代码
你可以建一个demo试试,就知道是不是你有什么代码导致的了