Is the size of a Form in Visual Studio designer limited to screen resolution?

后端 未结 8 568
时光取名叫无心
时光取名叫无心 2020-11-27 19:13

Why is it, that in the Visual Studio WinForms designer I cannot increase the size of my Form above the resolution of the screen I am currently working on? I think it should

8条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 19:41

    This worked for me, copied from

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    public class Form1 : Form
    {
        [DllImport("User32.dll", CharSet = CharSet.Ansi, SetLastError = true,    ExactSpelling = true)]
        private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool Repaint);
    
        private void Form1_Load(System.Object sender, System.EventArgs e)
        {
            this.MaximumSize = new Size(5000, 800);
            bool Result = MoveWindow(this.Handle, this.Left, this.Top, 5000, 500, true);
        }
        public Form1()
        {
            Load += Form1_Load;
        }
    
    }
    

提交回复
热议问题