简体   繁体   English

如何使Windows窗体充满整个屏幕

[英]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.

相关问题 如何在设计时使表单的大小填满整个屏幕? - How to make a form's size to fill all screen at design time? 如何使C#Windows窗体应用程序适合屏幕 - How to make a C# Windows Form Application fit to the screen 如何让我的 Windows 表单应用程序捕捉到屏幕边缘? - How to make my Windows Form app snap to screen edges? XAML:如何使堆栈面板充满屏幕? (WinRT) - XAML: How to make a stackpanel fill the screen? (WinRT) 背面摄像头无法充满屏幕Windows Phone 8.1的整个宽度 - Back Facing camera doesn't fill entire width of screen windows phone 8.1 如何让 XAML DataGridColumns 填充整个 DataGrid? - How do I make XAML DataGridColumns fill the entire DataGrid? 如何以编程方式使列和行填充整个 TableLayoutPanel - How to programmatically make columns and rows fill an entire TableLayoutPanel 如何使用 Docker 和 Anchor 属性使组件填充 Windows 表单中的所有可用空间? - How to make component fill all avaible space in Windows form using Docker and Anchor properties? 如何填写表格并使用 Windows 应用程序提交 - How to Fill form and submit using windows application 如何使 Windows 窗体适合 Windows 8 中的屏幕? - How to fit Windows Form to screen in Windows 8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM