[英]How to make a windows form fill the entire screen
I've got a function the creates a Bitmap and I pass this Bitmap to a function the creates a new Windows Form, a new PictureBox and I set the Image property of the PictureBox to the Bitmap. 我有一个函数,可以创建一个位图,然后将此位图传递给一个函数,可以创建一个新的Windows窗体,一个新的PictureBox,然后将PictureBox的Image属性设置为Bitmap。
Add the PictureBox to the new WindowsForm then .Show(); 将PictureBox添加到新的WindowsForm中,然后添加.Show();。 the new Form.
新表格。
I'm attempting to fill the entire screen with the new Form and fill the new Form with the new PictureBox and if there is any overflow I would like to have scroll bars; 我试图用新的Form填充整个屏幕,并用新的PictureBox填充新的Form,如果有任何溢出,我想使用滚动条; however, I cannot get the new Form to fill the window nor can I get the scroll bars to show.
但是,我无法获得新的窗体来填充窗口,也无法显示滚动条。
Any suggestions? 有什么建议么?
void ShowWindow(Bitmap elevation)
{
Form f = new Form();
f.Text = "CAD Drawing";
f.Dock = DockStyle.Fill;
PictureBox pb = new PictureBox();
pb.Image = elevation;
pb.Dock = DockStyle.Fill;
f.Controls.Add(pb);
f.BringToFront();
f.Show();
}
void ShowWindow(Bitmap elevation)
{
Form f = new Form();
f.Text = "CAD Drawing";
f.Dock = DockStyle.Fill;
f.WindowState = FormWindowState.Maximized;
Panel p = new Panel();
p.Dock = DockStyle.Fill;
p.AutoScroll = true;
p.BorderStyle = BorderStyle.FixedSingle;
PictureBox pb = new PictureBox();
pb.Image = elevation;
pb.Width = elevation.Width;
pb.Height = elevation.Height;
//pb.Focus();
p.Controls.Add(pb);
f.Controls.Add(p);
f.BringToFront();
f.Show();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.