❔ Get Informations of Form 1 in Form 2
Hello, I want to copie the Labeltext in Form 1 with the name "LinieValue" to Form2 inLabel4.
How can i do this?
11 Replies
you can pass the data in the constructor of Form2 (if some action in form1 opens form2)
you could also have a public property in form2 that you can set from wherever the form is being shown
Its probably easier to just pass a reference of the form itself to the other form
how can i do that?
im completly new so
how do you create your
Form2
instance?
and wherei created form 2 via project direcly and via a button Form1 closes and form2 opens
this.Hide();
Form2 form2 = new Form2();
form2.ShowDialog();
this.Close();
like this
okay
change the second line to
Form2 form2 = new Form2(this);
and update the form2 constructor to match
you now have a reference to form1 in form2so in form 2 i do?
EDIT: Got it
and how can i get with this a Text of a Label in Form1 to Form2?
well, you can now access things from form1 in form2
via that reference
so you'd make a public property that exposes the data you need from form1, then just access that in form2
so in a TextChanged Event i write "Form2.Label4.Text = StreckeValue.Text"?
I don't know what your code looks like my dude, I have no idea
something like this.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.