Solved

Visual C# Move data from one form to another

Posted on 2010-09-04
7
1,048 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Events in static methods 3 50
Not showing JavaScript in the list 5 38
C# HTTP GET method sample code 3 41
User Authentication using Digital Certificate 2 24
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

17 Experts available now in Live!

Get 1:1 Help Now