Solved

Visual C# Move data from one form to another

Posted on 2010-09-04
7
1,049 Views
Last Modified: 2012-05-10
I've created a windows form application that has a datagridview that when you select a row it populates text boxes. The question is when I change the data in the text boxes and click a submit button(Form1) I want it to go to another form(Form2) with a gridview that also has a button that will submit changes to another database. How would I go about doing this?
0
Comment
Question by:frtools
7 Comments
 
LVL 7

Expert Comment

by:jdavistx
ID: 33605170
So, you want to make changes to a DataGridView on Form 1, click a Button, and then be taken to Form 2 that has a Button that will be used to save the changes made in Form 1?
0
 

Author Comment

by:frtools
ID: 33605214
Form 1 has a datagrid that displays a query on a database. When I select a row the data is put into the text boxes. When the data is changed I want a submit button that post the data to another form with a data gridview that once I'm done making changes to data there is a submit button on the second form that posts the data back to a database.
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33605528
create a constructor in form2 which takes an object of datatype of actual gridrow in form1.
then in constructor pass the object when you are opening the form with the object at the selected row.

i hope this makes sense.
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 6

Expert Comment

by:aymoon80
ID: 33605728
you can make a function that performs the save operation and give it public access modifier

public void Save()
{
//write your own code for saving
}

//in you Form1 class define a variable of type Form2 say call it myForm2
private Form2 myForm2;
//in your form1 constructor pass form2 object:
public Form1(Form2 frm)
{
myForm2 = frm;
}

in your Form1 Submit button click event handler
write your saving code
then write
myForm2.Save();



0
 
LVL 6

Assisted Solution

by:aymoon80
aymoon80 earned 100 total points
ID: 33605731
if you want to access any Form2 variables pr methods only make sure to give them public access modifier and you can access it using your variable "myForm2" in your Form1 code
0
 
LVL 8

Accepted Solution

by:
Gururaj Badam earned 400 total points
ID: 33605878
1. Define an event on Form1
2. Subscribe on that event in Form2
3. On click of Form1.Button, raise the event
4. Put the data received in the Form2.Handler in the GridView
5. On click of Form2.Button - submit the changes.
0
 

Author Closing Comment

by:frtools
ID: 33627488
Both replies showed me the direction I Had to go.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question