Positioning a dialog in the center of the parent form

Posted on 2007-10-16
Last Modified: 2013-12-17
Hi Experts,

In my .Net C# GUI application, I want to display a dialog box from my parent form.  I created a new For class and was able to display it using the code snippet below.  But, the dialog does not appear in the center of the parent form.  How can I position it in the center?  I tried using setDesktopLocation( ) but it is not what I want.

                StartStop ss = new StartStop();
Question by:ambuli
    LVL 14

    Assisted Solution

    by:Daniel Junges
    you have to assign the parent form, like:

    StartStop ss = new StartStop();
    ss.MdiPatent = this;
    ss.StartPosition = FormStartPosition.CenterParent;
    LVL 22

    Accepted Solution

    Try this:
    ss.StartPosition = FormStartPosition.CenterParent;

    then show the dialog.

    LVL 85

    Assisted Solution

    by:Mike Tomlinson can't use ShowDialog() with MdiChildren...

    LVL 14

    Expert Comment

    by:Daniel Junges
    you are right Idle_Mind, Ambuli have to use ss.Show()  instead ss.ShowDialog().

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now