Click here to Skip to main content
16,022,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two forms which are both open. I want to send a datagridview cell value from form 1 (already open) to form 2 (already ope. (I don't want to pass text on form load, but after some edits on the already open form). I've searched the web for days but I can't find one for already open forms. (Only those containing form.show() property).

What I have tried:

private void button_click(object sender, EventArgs e)
{
Form 1 form = new Form1();
form.lblName.text = txtName.text;
}
Posted
Updated 27-Jan-19 2:38am
Comments
[no name] 27-Jan-19 8:45am    
You are creating a new (temporary) Form1 form in this method so it will be destroyed as soon as the method returns.

1 solution

Exactly how depends on the "relationship" between the two forms.
Have a look at these, one of them will fit your circumstances.
The form that creates an instance of another:
C#
MyForm mf = new MyForm();
mf.Show();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900