I create a new form and call from the parent form as follows:
loginForm = new SubLogin();
loginForm.Show();
I need to display the chi
Make a Windows Form , then put option for it : CenterParent then use this Code :
yourChildFormName x = new yourChildFormName();
x.ShowDialog();
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
CenterToParent();
}
As a sub form i think it's not gonna Start in the middle of the parent form until you Show it as a Dialog.
..........
Form2.ShowDialog();
i was about to make About Form. and this is perfect that's i am searching for. and untill you close the About_form you cant Touch/click anythings of parents Form once you Click for About_Form (in my case) .Coz its Showing as Dialog
Why not use this?
LoginForm.WindowStartupLocation = Windows.WindowStartupLocation.CenterOwner
(vb.net)
It works in all cases, swap Form1 for your main form.
Popup popup = new Popup();
popup.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
popup.Location = new System.Drawing.Point((Form1.ActiveForm.Location.X + Form1.ActiveForm.Width / 2) - (popup.Width / 2),(Form1.ActiveForm.Location.Y + Form1.ActiveForm.Height / 2) - (popup.Height / 2));
popup.Show(Form1.ActiveForm);
When you want to use a non-blocking window (show() instead of showDialog()), this not work:
//not work with .Show(this) but only with .ShowDialog(this)
loginForm.StartPosition = FormStartPosition.CenterParent;
loginForm.Show(this);
In this case, you can use this code to center child form before display the form:
//this = the parent
frmDownloadPercent frm = new frmDownloadPercent();
frm.Show(this); //this = the parent form
//here the tips
frm.Top = this.Top + ((this.Height / 2) - (frm.Height / 2));
frm.Left = this.Left + ((this.Width / 2) - (frm.Width / 2));