?
Solved

Visual C# Move data from one form to another

Posted on 2010-09-04
7
Medium Priority
?
1,053 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 400 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 1600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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