how moving a secondary form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to move a secondary form to the main form's center. But this does
not work with the code I try. Can someone explain ?

Form1 is my seond form. And this is menu item click from main form:

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
Point loc = new Point();
Form1 about = new Form1();
loc.X = Location.X + (Size.Width - about.Size.Width) / 2;
loc.Y = Location.Y + (Size.Height - about.Size.Height) / 2;
about.Location = loc;
//about.Show(this);
about.ShowDialog();
}
 
Hi,

I'm trying to move a secondary form to the main form's center. But this does
not work with the code I try. Can someone explain ?

<snip>code to try to manually center the form</snip>

Why not just set the StartPosition on your secondary form to CenterParent?
 
Hi Tom,

Thank you. That works as a glance, But still Im wondering wy the other did
not work. In some applications I will put a form for example on a known or
preivious place (eg position / size saved in config file) ?

rgds, Wilfried
 
Hi Tom,

Thank you. That works as a glance, But still Im wondering wy the other did
not work. In some applications I will put a form for example on a known or
preivious place (eg position / size saved in config file) ?

rgds, Wilfried

If you want to manually set the start position on your form, then you need
to set the StartPosition property on the form to Manual. It should then
use the Location you specify.
 
Back
Top