Solved

Visual C# Move data from one form to another

Posted on 2010-09-04
7
1,047 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

by:aymoon80
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Both replies showed me the direction I Had to go.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now