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. Owned Forms issue

Owned Forms issue

Scheduled Pinned Locked Moved C#
helpquestion
10 Posts 3 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.
  • S Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    Hi all, To be precise, I have a winform (say form A) with buttons on it, which when clicked, opens up new forms (say b, c, d). I want to set form A as the owner and forms b,c,d as owned forms of form A. The basic thing which I am looking to achieve is that when I close form A , I want to close all other owned forms and warn the user that some forms that belong to form A are already open and if they would like to close it? FYI - form A is already a ChildForm of a MDI parent in my application. Any help will be appreciated. Thanks,

    L 1 Reply Last reply
    0
    • S spankyleo123

      Hi all, To be precise, I have a winform (say form A) with buttons on it, which when clicked, opens up new forms (say b, c, d). I want to set form A as the owner and forms b,c,d as owned forms of form A. The basic thing which I am looking to achieve is that when I close form A , I want to close all other owned forms and warn the user that some forms that belong to form A are already open and if they would like to close it? FYI - form A is already a ChildForm of a MDI parent in my application. Any help will be appreciated. Thanks,

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, inside class FormA, instead of doing formB.Show() or formB.ShowDialog(), do formB.Show(this) or formB.ShowDialog(this). :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, inside class FormA, instead of doing formB.Show() or formB.ShowDialog(), do formB.Show(this) or formB.ShowDialog(this). :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        S Offline
        S Offline
        spankyleo123
        wrote on last edited by
        #3

        thanks for your reply, But the problem is, I want the form to be displayed within the MDI parent container. If I use Show() or ShowDialogue() the form is displayed outside the MDI parent container.

        L 1 Reply Last reply
        0
        • S spankyleo123

          thanks for your reply, But the problem is, I want the form to be displayed within the MDI parent container. If I use Show() or ShowDialogue() the form is displayed outside the MDI parent container.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          then try something like this:

          FormB formB = new FormB();
          formB.MdiParent = this;
          formB.Show();

          :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          S 1 Reply Last reply
          0
          • L Luc Pattyn

            then try something like this:

            FormB formB = new FormB();
            formB.MdiParent = this;
            formB.Show();

            :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            S Offline
            S Offline
            spankyleo123
            wrote on last edited by
            #5

            Hi thanks for your reply. Am getting this exception error when I write Ur code. "Form that was specified to be the MdiParent for this form is not an MdiContainer. Parameter name: value "

            L D 2 Replies Last reply
            0
            • S spankyleo123

              Hi thanks for your reply. Am getting this exception error when I write Ur code. "Form that was specified to be the MdiParent for this form is not an MdiContainer. Parameter name: value "

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              then fix the error. stuff the parent where it goes. :|

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              S 1 Reply Last reply
              0
              • L Luc Pattyn

                then fix the error. stuff the parent where it goes. :|

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                S Offline
                S Offline
                spankyleo123
                wrote on last edited by
                #7

                Mate, This is the hierarchy of my app. MDIParent > MDIChild > buttons to open additional forms. these forms appear in the MDI Container if I set

                form.MDIParent = this.MDIParent

                But my question is When I close the child form, I want to close all other open forms which are opened through button clicks?

                L 1 Reply Last reply
                0
                • S spankyleo123

                  Mate, This is the hierarchy of my app. MDIParent > MDIChild > buttons to open additional forms. these forms appear in the MDI Container if I set

                  form.MDIParent = this.MDIParent

                  But my question is When I close the child form, I want to close all other open forms which are opened through button clicks?

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  maybe this[^] helps? :doh:

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  S 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    maybe this[^] helps? :doh:

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                    S Offline
                    S Offline
                    spankyleo123
                    wrote on last edited by
                    #9

                    Thats the whole issue mate. If I say

                    Show(this) or ShowDialog(this)

                    I get the error which says "Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog." Ohh I better ask Uncle Google instead. Cheers

                    1 Reply Last reply
                    0
                    • S spankyleo123

                      Hi thanks for your reply. Am getting this exception error when I write Ur code. "Form that was specified to be the MdiParent for this form is not an MdiContainer. Parameter name: value "

                      D Offline
                      D Offline
                      DaveyM69
                      wrote on last edited by
                      #10

                      you need to set the IsMdiContainer (IIRC) property to true in the parent form.

                      Dave

                      If this helped, please vote & accept answer!

                      Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
                      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                      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