c# - Value of the label is modified, but not changed in the form -
well, have 2 forms here , want pass info secondary form (adduserform) primary (form1). problem is not working. exemple, set in form1 following:
adduserform secondaryform = new adduserform(); secondaryform.label1.text = "i created in adduserform , alter text here in form1!";
this works. can utilize alter value , text of label of adduserform in form1, not vice-versa. see this, using same method in secondary form:
form1 primaryform = new form1(); primaryform.label1.text = "i created in form1 , alter text here in adduserform!";
this don't work! label text not change! i've used messagebox show me content of label, , showed me indicated text (i created in form1 , alter text here in adduserform!)by way can conclude value of label changed text in form remain same! why don't work if add together reference in secondary form? can help? need solve this! in advance!
your code shows creating new instance of form1
when trying set label1.text
instead of referencing existing form1
. need variable in adduserform
can hold reference form1
.
you should add together next adduserform:
public form1 myform1;
then, alter first code block (assuming form1
what's creating adduserform
)
adduserform secondaryform = new adduserform(); secondaryform.myform1 = this; secondaryform.label1.text = "text";
and alter sec code block to:
myform1.label1.text = "text";
c# .net winforms label
No comments:
Post a Comment