473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passing data between forms?

How would I send information from DataGrid on the main form of the
application to a modal popup form and then pass any changes to the data back
to the main form and database when the popup form was closed?

Thanks
Jul 21 '05 #1
4 1666
Assuming that you know how to read the data in question from the datagrid and
update it, you can:

1)from the event handler that you want to use to fire the modal popup form,
ensure that the required data is passed:

Private Sub MainForm_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
Dim Other As ModalPopupForm

Other = New ModalPopupForm
Other.DataToBeEdited = dataToBeEdited '
Other.Show()
End Sub

2)In the desired event in the modal popup, ensure that updated data is
propagated back into the datagrid. Since it is a modal popup, I suggest

Private Sub ModalPopupForm_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim closingForm As ModalPopupForm
closingForm = CType(sender, ModalPopupForm)
updateDataGrid(closingForm.EditedData)
End Sub

To finish this, you must implement the ModalPopupForm's DataToBeEdited and
EditedData properties, as well as the updateDataGrid-method.
Alternatively, you can pass the datagrid itself as the
'DataToBeEdited'-property. In this case you can drop implementing
updateDataGrid at all, but this latter approach creates an extremely tight
coupling between MainForm and ModalPopupForm which is generally not desirable.

Tor BÃ¥dshaug
tor.badshaug(AT)bekk.no
Jul 21 '05 #2
Job,

When you ask this kind of question in this newsgroup, tell than next time if
you use C# or VBNet. Althoug a language newsgroup is in my opinion more
proper. It can in VBNet be something as

Dim frm as myPopupForm
frm.datafromGrid = DataFromGrid
frm.showdialog
WhateverIWantfromMyPopupForm = frm.WhateverIWant
frm.dispose

I hope this helps,

Cor
Jul 21 '05 #3
someone suggested me this which seems quite straight forward

I would use the method of showing the add/edit window(s) as dialog forms
from the main form. This will allow you to instantiate the add/edit window
from the same form as your datagrid/datasource. You can then get the current
row from the datasource and use it as the datasource for databinding to
controls on the add/edit form. After the user is finished with the add/edit
form and they click ok, you can call update on your dataadapter(s). This
method makes it easy because you can do everything from a single routine. You
don't really need to pass a lot of references between forms; just set and
read the property values of the controls on the add/edit form.
"Cor Ligthert" wrote:
Job,

When you ask this kind of question in this newsgroup, tell than next time if
you use C# or VBNet. Althoug a language newsgroup is in my opinion more
proper. It can in VBNet be something as

Dim frm as myPopupForm
frm.datafromGrid = DataFromGrid
frm.showdialog
WhateverIWantfromMyPopupForm = frm.WhateverIWant
frm.dispose

I hope this helps,

Cor

Jul 21 '05 #4
someone suggested me this which seems quite straight forward

I would use the method of showing the add/edit window(s) as dialog forms
from the main form. This will allow you to instantiate the add/edit window
from the same form as your datagrid/datasource. You can then get the current
row from the datasource and use it as the datasource for databinding to
controls on the add/edit form. After the user is finished with the add/edit
form and they click ok, you can call update on your dataadapter(s). This
method makes it easy because you can do everything from a single routine. You
don't really need to pass a lot of references between forms; just set and
read the property values of the controls on the add/edit form.
"Tor BÃ¥dshaug" wrote:
Assuming that you know how to read the data in question from the datagrid and
update it, you can:

1)from the event handler that you want to use to fire the modal popup form,
ensure that the required data is passed:

Private Sub MainForm_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
Dim Other As ModalPopupForm

Other = New ModalPopupForm
Other.DataToBeEdited = dataToBeEdited '
Other.Show()
End Sub

2)In the desired event in the modal popup, ensure that updated data is
propagated back into the datagrid. Since it is a modal popup, I suggest

Private Sub ModalPopupForm_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim closingForm As ModalPopupForm
closingForm = CType(sender, ModalPopupForm)
updateDataGrid(closingForm.EditedData)
End Sub

To finish this, you must implement the ModalPopupForm's DataToBeEdited and
EditedData properties, as well as the updateDataGrid-method.
Alternatively, you can pass the datagrid itself as the
'DataToBeEdited'-property. In this case you can drop implementing
updateDataGrid at all, but this latter approach creates an extremely tight
coupling between MainForm and ModalPopupForm which is generally not desirable.

Tor BÃ¥dshaug
tor.badshaug(AT)bekk.no

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
5
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a...
0
by: Eric Sabine | last post by:
OK, I'm trying to further my understanding of threading. The code below I wrote as kind of a primer to myself and maybe a template that I could use in the future. What I tried to do was pass data...
2
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread...
1
by: SteveDouglas | last post by:
Hi all, I am currently writing an application in VB.NET that has a lot of controls (treeviews/listviews/labels and so forth) that represent "things" that need to be draggable from place to place,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.