Visual Studio 2012를 사용하고 있습니다. 열 때 내 양식이 화면 가운데에 있지 않습니다. 양식의 StartPosition
은 CenterScreen
으로 설정되어 있지만 항상 왼쪽 모니터의 왼쪽 상단에서 시작됩니다 (2 대의 모니터가 있음).StartPosition이 CenterPosition으로 설정되었지만 내 양식이 가운데에 맞춰지지 않았습니다.
아이디어가 있으십니까? 감사합니다
Visual Studio 2012를 사용하고 있습니다. 열 때 내 양식이 화면 가운데에 있지 않습니다. 양식의 StartPosition
은 CenterScreen
으로 설정되어 있지만 항상 왼쪽 모니터의 왼쪽 상단에서 시작됩니다 (2 대의 모니터가 있음).StartPosition이 CenterPosition으로 설정되었지만 내 양식이 가운데에 맞춰지지 않았습니다.
아이디어가 있으십니까? 감사합니다
이런 식으로 시도하십시오!
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Method 1. center at initilization
this.StartPosition = FormStartPosition.CenterScreen;
//Method 2. The manual way
this.StartPosition = FormStartPosition.Manual;
this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height)/2;
this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width)/2;
}
}
}
두 개의 가상 멤버가 응용 프로그램의 생성자에서 호출됩니다.
즉
this.Text;
this.MaximumSize;
은 비정상적인 행동
고정 코드 생성자가 나를 위해 작동에 배치
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Location = new System.Drawing.Point(100, 100);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
// to see if form is being centered, disable maximization
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Convertor";
this.MaximumSize = new System.Drawing.Size(620, 420);
}
}
}
방법 1 또는 2가 작동하지 않았습니다. 이것은 form1의 초기화 코드입니다. - this.Location = new System.Drawing.Point (100, 100); this.MaximumSize = new System.Drawing.Size (620, 420); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Convertor"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load + = new System.EventHandler (this.Form1_Load); this.ResumeLayout (false); this.PerformLayout(); – user1936588
지금 확인하세요! lmk! –
그 덕분에 AppDeveloper! – user1936588
로 이어질 수 생성자에서 가상 멤버를 호출하지 않습니다. 몇 가지 코드를 보여 주시겠습니까? – Mir
어떤 코드를보아야합니까? 양식의 속성을 사용하여 설정할 수 있다는 인상을 받고 있었습니까? – user1936588
'StartPosition = FormStartPosition.CenterScreen; '을 배치하고 디자이너에서 설정하여 나에게 적합합니다. 덮어 쓰거나 설정을 방해하는 코드가 있는지 확인하도록 코드를 요청했습니다. – Mir