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. How to pass value from child form to parent form

How to pass value from child form to parent form

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
5 Posts 5 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.
  • E Offline
    E Offline
    ejaz_pk
    wrote on last edited by
    #1

    I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz

    J V B K 4 Replies Last reply
    0
    • E ejaz_pk

      I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz

      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      Someone may suggest modifying the constructor of the forms, or having a method to pass the data, etc. However, Pete O'Halon with slap anyone that suggests that. You should implement the Model-view-controller design pattern.[^] Read up on it. It'll make you a better "developer" :)

      I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

      1 Reply Last reply
      0
      • E ejaz_pk

        I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz

        V Offline
        V Offline
        Vanamaindia
        wrote on last edited by
        #3

        This is help for u.. use this stmt in child window javascript window.returnValue=document.getElementById('<%=hfldConCatStr.ClientID%>').value; use this in parent window var retVal=window.showModalDialog('dsfdf.aspx');

        1 Reply Last reply
        0
        • E ejaz_pk

          I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz

          B Offline
          B Offline
          BooleanTrue
          wrote on last edited by
          #4

          Ejaz Bhai! try this, Its simple to implement.... in Parent Form use this: dim myVal as integer Public Property SetVal() As Integer Get Return myVal End Get Set(ByVal value As Integer) myVal = value End Set End Property in child form: dim parentObj as [parentForm] parentObj.SetVal = [Any Integer Valu] now close child form and use variable 'myVal' in parent form as output from child form.

          colgateas900197

          1 Reply Last reply
          0
          • E ejaz_pk

            I am using to forms (Transactions Form and ProductList Form) The transactions form is a parent form and there is a button to show the productlist form which shows all the available products in a gridview control.I am using showdialog method to open the productlist form.Once the productlist form is open then user can not do anything on the parent form unless he close the productlist form which I think is clear from showdialog method. Now what I want is that when user select any row from the datagridview from productlist form and click ok button then the value of the first column of the selected row should be updated in the parent form's textbox (txtProduct) and the productlist form will be closed. The datagridview on the productlist form is bound to a datatable. Any idea how I can pass the value from the child form to parent form? Thanks in advance Ejaz

            K Offline
            K Offline
            KarstenK
            wrote on last edited by
            #5

            I normally make data and view objects and every view can access the data so it can easily be shown and changed. The data object is globally and unique. If data gets changed you got to trigger an update, in your case check whether the dialog returns with OK => Reload from data object.

            Greetings from Germany

            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