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. Parent Form

Parent Form

Scheduled Pinned Locked Moved C#
questioncsharpvisual-studiowinformshelp
3 Posts 2 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.
  • J Offline
    J Offline
    John L DeVito
    wrote on last edited by
    #1

    here's what I'm sure is an easy one... I have a project with 5 different windows forms. One is the main program form and 4 of them are displayed by clicking a button on the main form. I'm trying to get each form centered on the main form (they are all modal dialogs). I've chosen "center on parent" on the property sheet for each form, but each form is still spawning what seems to be randomly on screen. I don't think that the main form of the project is set as the parent form for each of the other forms. Is this what the problem is and if so how can I go about giving each form a child relationship to the main form? Thanks, John BTW I'm using Visual Studio 2005 Standard Edition. -- modified at 21:06 Friday 9th December, 2005

    J 1 Reply Last reply
    0
    • J John L DeVito

      here's what I'm sure is an easy one... I have a project with 5 different windows forms. One is the main program form and 4 of them are displayed by clicking a button on the main form. I'm trying to get each form centered on the main form (they are all modal dialogs). I've chosen "center on parent" on the property sheet for each form, but each form is still spawning what seems to be randomly on screen. I don't think that the main form of the project is set as the parent form for each of the other forms. Is this what the problem is and if so how can I go about giving each form a child relationship to the main form? Thanks, John BTW I'm using Visual Studio 2005 Standard Edition. -- modified at 21:06 Friday 9th December, 2005

      J Offline
      J Offline
      Jared Parsons
      wrote on last edited by
      #2

      You are correct. For them to properly center they must have the parent form set. To do this just pass in the parent form as the first paramater to the ShowDialog() method. For instance public void OnButtonClick(object sender, EventArgs e) { SomeForm child = new SomeForm(); if ( DialogResult.OK == child.ShowDialog(this) ) { ... } } Jared Parsons jaredp@beanseed.org http://spaces.msn.com/members/jaredp/

      J 1 Reply Last reply
      0
      • J Jared Parsons

        You are correct. For them to properly center they must have the parent form set. To do this just pass in the parent form as the first paramater to the ShowDialog() method. For instance public void OnButtonClick(object sender, EventArgs e) { SomeForm child = new SomeForm(); if ( DialogResult.OK == child.ShowDialog(this) ) { ... } } Jared Parsons jaredp@beanseed.org http://spaces.msn.com/members/jaredp/

        J Offline
        J Offline
        John L DeVito
        wrote on last edited by
        #3

        Thanks a bunch Jared, got it working :) Thanks, John

        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