我的 Winforms 应用程序中的窗口位置存在问题。
我需要在启动过程中将窗口定位在屏幕中央。我尝试了以下但没有奏效。表单始终在左上角打开。
我在加载事件中尝试了这些:
this.CenterToScreen();
this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
(Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
更新:我已将表格的最大和最小尺寸设为 1090,726。
我的设计器文件有这个代码:
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.GrayText;
this.ClientSize = new System.Drawing.Size(1074, 688);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(1090, 726);
this.MinimumSize = new System.Drawing.Size(1090, 726);
this.Name = "Mail_Remainder";
this.RightToLeftLayout = true;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Remainder";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Mail_Remainder_Load);
this.Resize += new System.EventHandler(this.Mail_Remainder_Resize);
this.ResumeLayout(false);
this.PerformLayout();
还有其他方法可以做到这一点吗?
请帮忙。