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. Visual Basic
  4. showModalDialog

showModalDialog

Scheduled Pinned Locked Moved Visual Basic
tutorial
10 Posts 3 Posters 1 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.
  • R Offline
    R Offline
    Rahithi
    wrote on last edited by
    #1

    Hi all, i am using showModalDialog to open the popup window. I am sending one object from parent window to child window and doing some processing in child window. Now I have to set the values in the parent window based on the calculations in the child window. I came to know that from the child window, we can set the values for the controls which are in parent. I appreciate if some one can let me know how to do this….. Thanks in advance, Rahi

    If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

    P 1 Reply Last reply
    0
    • R Rahithi

      Hi all, i am using showModalDialog to open the popup window. I am sending one object from parent window to child window and doing some processing in child window. Now I have to set the values in the parent window based on the calculations in the child window. I came to know that from the child window, we can set the values for the controls which are in parent. I appreciate if some one can let me know how to do this….. Thanks in advance, Rahi

      If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      This article, http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp[^] may be of help for you...

      "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      R 1 Reply Last reply
      0
      • P Paul Conrad

        This article, http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp[^] may be of help for you...

        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        R Offline
        R Offline
        Rahithi
        wrote on last edited by
        #3

        Thanks Paul for responding to my query. I saw this article. Nice one. Unfortunately, I didn't find the solution for my problem. In this Article, Colin focused on passing the data from Parent to child but not child to parent. I am sending some data from the parent form to child in the form of object, when the user closes the popup window; I want to populate the controls which are placed on parent form, with the data which is processed in child form. Thanks, Rahi -- modified at 23:45 Saturday 28th July, 2007

        If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

        P 1 Reply Last reply
        0
        • R Rahithi

          Thanks Paul for responding to my query. I saw this article. Nice one. Unfortunately, I didn't find the solution for my problem. In this Article, Colin focused on passing the data from Parent to child but not child to parent. I am sending some data from the parent form to child in the form of object, when the user closes the popup window; I want to populate the controls which are placed on parent form, with the data which is processed in child form. Thanks, Rahi -- modified at 23:45 Saturday 28th July, 2007

          If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          I thought you were going from child to parent, my misunderstanding :-O Good way to pass data from parent to child could be to modify the constructor for the child form to have a parameter that is the data you want to pass. For example, if I wanted to pass a string from MyTextBox.text from the parent to child, I could do something like:

               ...
               Dim MyChildForm As New ChildForm( MyTextBox.text )
               MyChildForm.Show ' or ShowDialog
          

          In the code for ChildForm, you would have the constructor look like:

               Dim Private MyParentString As String
          
               Public Sub New(ByVal MyTextString As String)
                    MyParentString = MyTextString
               End Sub
          

          Change the form names to the ones you are using, and the data and datatype of what you are passing.

          "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          R 1 Reply Last reply
          0
          • P Paul Conrad

            I thought you were going from child to parent, my misunderstanding :-O Good way to pass data from parent to child could be to modify the constructor for the child form to have a parameter that is the data you want to pass. For example, if I wanted to pass a string from MyTextBox.text from the parent to child, I could do something like:

                 ...
                 Dim MyChildForm As New ChildForm( MyTextBox.text )
                 MyChildForm.Show ' or ShowDialog
            

            In the code for ChildForm, you would have the constructor look like:

                 Dim Private MyParentString As String
            
                 Public Sub New(ByVal MyTextString As String)
                      MyParentString = MyTextString
                 End Sub
            

            Change the form names to the ones you are using, and the data and datatype of what you are passing.

            "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

            R Offline
            R Offline
            Rahithi
            wrote on last edited by
            #5

            Sorry Paul, i sent the wrong message...just now i modified my message. i am able to pass the data(in the form of object) from parent to child. my problem is i have to pass the data from child to parent. when user clicks on Close Button on child(pop-up window), i have to populate the controls which are on Parent form. Thanks once again for your response... Rahithi

            If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

            P 1 Reply Last reply
            0
            • R Rahithi

              Sorry Paul, i sent the wrong message...just now i modified my message. i am able to pass the data(in the form of object) from parent to child. my problem is i have to pass the data from child to parent. when user clicks on Close Button on child(pop-up window), i have to populate the controls which are on Parent form. Thanks once again for your response... Rahithi

              If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              The child form, you could overload the Close method with something like:

                   Overloads Function Close() As {  Your-DataType-Of-Data-To-Pass-Back  }
                        Return {  The-Data-You-Want-Parent-To-Get-From-Child  }
                   End Function
              

              "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

              R 1 Reply Last reply
              0
              • P Paul Conrad

                The child form, you could overload the Close method with something like:

                     Overloads Function Close() As {  Your-DataType-Of-Data-To-Pass-Back  }
                          Return {  The-Data-You-Want-Parent-To-Get-From-Child  }
                     End Function
                

                "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                R Offline
                R Offline
                Rahithi
                wrote on last edited by
                #7

                Ok!! i will try this . but one more simple doubt.........is it possible to directly populate the data in the parent controls using this overloaded close function?? Many Thanks, Rahi

                If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                P J 2 Replies Last reply
                0
                • R Rahithi

                  Ok!! i will try this . but one more simple doubt.........is it possible to directly populate the data in the parent controls using this overloaded close function?? Many Thanks, Rahi

                  If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #8

                  Are you loading a dataset or something like that (datatable adapter, datarows, etc) in the child form? If so, pass the dataset back as a return value from the overloaded Close function.

                  "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  R 1 Reply Last reply
                  0
                  • P Paul Conrad

                    Are you loading a dataset or something like that (datatable adapter, datarows, etc) in the child form? If so, pass the dataset back as a return value from the overloaded Close function.

                    "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                    R Offline
                    R Offline
                    Rahithi
                    wrote on last edited by
                    #9

                    paul, thanks alot for your answer!!!!! i am sending Collection (object) to child window. almost 20 records(30 columns per record) of data but now i need only 4 values (need to populate 4 text box controls)from child window. i heard that if we use Show model dialogue to open the pop-up window, we can directly access the Parent winodow controls in the pop-up window, so that we can set the values directly from child window it self..i mean no need to pass the data using sessions..or anything... please discard my statement if it is wrong.......i am new to .Net technology.......this is my first project. when user hits on Close button on child window, parent window gets focused....at the same time we have to show these values on parent. any idea??????????? Thanks, Rahi

                    If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                    1 Reply Last reply
                    0
                    • R Rahithi

                      Ok!! i will try this . but one more simple doubt.........is it possible to directly populate the data in the parent controls using this overloaded close function?? Many Thanks, Rahi

                      If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                      J Offline
                      J Offline
                      Jeff Bowman
                      wrote on last edited by
                      #10

                      Hi Rahithi Add this property to your child form:

                      Private Readonly Property OwnerForm As ParentForm
                      Get
                      Return Me.OwnerForm
                      End Get
                      End Property

                      Now you can access any property you expose on your parent form from your child form's Close event. HTH

                      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