'Windows Form Cannot be Displayed CenterScreen
I used this code for the secondary form to act / be like mdi, this is windows form C#
frmFontLoad fontLoad = new frmFontLoad();
fontLoad.TopLevel = false;
Controls.Add(fontLoad);
fontLoad.Show();
fontLoad.BringToFront();
but the result then the form was loaded is like this refer to screenshot:
Code on Form Load:
private void frmLabelPNInput_Load(object sender, EventArgs e)
{
this.StartPosition = FormStartPosition.CenterScreen;
Printer_SerialPort = new SerialPort(ConfigurationManager.AppSettings["Printer_com_port"]);
btnOk.Enabled = false;
}
how can i make this secondary form to be displayed at the center?
Solution 1:[1]
frmProgress progress = new frmProgress();
progress.Left = (this.ClientSize.Width - progress.Width) / 2;
progress.Top = (this.ClientSize.Height - progress.Height) / 2;
This solved my problem, thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mario Luigi Vibal |