473,657 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1683
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_Double Click(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.DoubleCl ick
Dim Other As ModalPopupForm

Other = New ModalPopupForm
Other.DataToBeE dited = 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.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Dim closingForm As ModalPopupForm
closingForm = CType(sender, ModalPopupForm)
updateDataGrid( closingForm.Edi tedData)
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.datafromGri d = DataFromGrid
frm.showdialog
WhateverIWantfr omMyPopupForm = frm.WhateverIWa nt
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.datafromGri d = DataFromGrid
frm.showdialog
WhateverIWantfr omMyPopupForm = frm.WhateverIWa nt
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_Double Click(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.DoubleCl ick
Dim Other As ModalPopupForm

Other = New ModalPopupForm
Other.DataToBeE dited = 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.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Dim closingForm As ModalPopupForm
closingForm = CType(sender, ModalPopupForm)
updateDataGrid( closingForm.Edi tedData)
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
3959
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
12
6533
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 courses to pass the correct option value and then be displayed at the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing countries, products, and courses. The first two display
2
2531
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, radio, checkbox, and dropdown. When the form Submit button is clicked, I then need the input data either written to another location on the same page, or written to another page (a different frame would be fine)
11
3473
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 click a button to determine whether the zip code is unique. If the zip code is not unique, another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip code and zipid are both passed to the lookup form/dialog by reference. I...
8
4407
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 click a button to determine whether the zip code is unique. If the zip code is not unique, another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip code is passed to the lookup form/dialog by reference. I then load a...
6
3248
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 query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the calling page. On the both pages I have a property of the page which is an instance of this custom...
5
2115
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 button and just using the data during postback. Now, however, I've got a WebForm that I'll be working on, and it is going to collect more data than I have collected from the user in the past. I want to be able to attempt to save each part and if...
0
1477
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 into a background thread and get other data out and also update the main thread on which the main form was created. It seems to work fine. The basic function of the app is cheesy, I didn't spend any time on exception handling. northwind.mdb...
2
2589
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 out the work. The order of work is as follows: 1. Retrieve the data from primary data source 2. Update UI with retrieved data - this is accomplished by passing a dataset as an event parameter
1
2305
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, including between controls and windows. In the past when I've implemented Drag and Drop in other projects, I've always passed the item being dragged (for example the listviewitem or the treenode) to the DoDragDrop and then retrieved it in the...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8504
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.