Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Form.ShowDialog() messing uo location and size

Form.ShowDialog() messing uo location and size

Form.ShowDialog() messing uo location and size

Why is it that when I call ShowDialog() on my form, it resizes the form and relocates it to a seemingly random size and location? I don't seem to have any control over it.

I can gain some control over the size of the form if I attempt to reset its location as follows:

            DataSourceForm dataSourceForm = new DataSourceForm();
            dataSourceForm.Location = new System.Drawing.Point(
                this.Location.X + DataSourceForm.OFFSET_X, this.Location.Y + DataSourceForm.OFFSET_Y);

where "this" refers to a parent dialog box (so I'm positioning my form relative to the parent).

But this, ironically, restores the size of my form as seen in the Visual Studios designer but does not set its location. It would be nice if ShowDialog didn't take control of the size or the location so that I can set both in either the designer or in the constructor without worry that they will change later on.

RE: Form.ShowDialog() messing uo location and size

The constructor value will be used as long as you are calling that constructor. The size of your form is independent of the location of the form on your screen.

You are setting the location based on WHATEVER spawned the window. If you are doing something that is causing the form to be shown while in the VS environment (which can happen), then you need to be aware of that during development, but when you run your app it should behave normally.


You've got questions and source code. We want both!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close