passing value from one form to another
-
can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..
pradip kishore
-
can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..
pradip kishore
form_month needs to know about form_main In form_month:-
Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub
In form_main:-Public Class form_main Dim m_form_month As New form_month(Me)
in the code for the submit button to open form_month:-m_form_month.Show()
in the code for the load event for form_month read the value of tbid:-Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text
hope this helps Alex -
can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..
pradip kishore
See: Passing Values between Forms[^]
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
form_month needs to know about form_main In form_month:-
Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub
In form_main:-Public Class form_main Dim m_form_month As New form_month(Me)
in the code for the submit button to open form_month:-m_form_month.Show()
in the code for the load event for form_month read the value of tbid:-Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text
hope this helps AlexThat would work, but the problem is you need to make your controls public. Instead, you should expose properties, or use delegates, to hide as much detail of your class as possible.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
form_month needs to know about form_main In form_month:-
Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub
In form_main:-Public Class form_main Dim m_form_month As New form_month(Me)
in the code for the submit button to open form_month:-m_form_month.Show()
in the code for the load event for form_month read the value of tbid:-Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text
hope this helps AlexHi Alex thanks a lot for your simple and quick response..
pradip kishore