Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Show Form in Center

Show Form in Center

Scheduled Pinned Locked Moved C#
help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foysal mamun
    wrote on last edited by
    #1

    i cannt show a form in center of its parent form. i use to show "form1.ShowDialog();" plx help me;

    T N L 3 Replies Last reply
    0
    • F foysal mamun

      i cannt show a form in center of its parent form. i use to show "form1.ShowDialog();" plx help me;

      T Offline
      T Offline
      tjvictor
      wrote on last edited by
      #2

      you can set form position property .

      T 1 Reply Last reply
      0
      • T tjvictor

        you can set form position property .

        T Offline
        T Offline
        tjvictor
        wrote on last edited by
        #3

        setting property like this: this.StartPosition = FormStartPosition.CenterScreen;

        F 1 Reply Last reply
        0
        • T tjvictor

          setting property like this: this.StartPosition = FormStartPosition.CenterScreen;

          F Offline
          F Offline
          foysal mamun
          wrote on last edited by
          #4

          but it dose not work. it show at topleft conner. i can solve the problem by setting the properties. plz help..

          1 Reply Last reply
          0
          • F foysal mamun

            i cannt show a form in center of its parent form. i use to show "form1.ShowDialog();" plx help me;

            N Offline
            N Offline
            Nader Elshehabi
            wrote on last edited by
            #5

            Hello This should Do it: private void MyShowMethod() { Form1 form = new Form1(); form1.StartPosition = FormStartPosition.Manual; int X = Left + Width / 2 - form1.Width / 2; int Y = Top + Height / 2 - form1.Height / 2; form1.Location = new Point(X, Y); form1.ShowDialog(); } Regards:rose:

            1 Reply Last reply
            0
            • F foysal mamun

              i cannt show a form in center of its parent form. i use to show "form1.ShowDialog();" plx help me;

              L Offline
              L Offline
              LongRange Shooter
              wrote on last edited by
              #6

              Open the form in Visual Studio. Look at the properties for that window. Change StartPosition from WindowsDefaultLocation to CenterParent. :suss:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups