• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1055
  • Last Modified:

Visual C# Move data from one form to another

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
frtools
Asked:
frtools
2 Solutions
 
jdavistxCommented:
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
 
frtoolsAuthor Commented:
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
 
puru1981Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
aymoon80Commented:
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
 
aymoon80Commented:
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
 
Gururaj BadamCommented:
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
 
frtoolsAuthor Commented:
Both replies showed me the direction I Had to go.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now