My program has two forms. I'm trying to define the global value, "Name" on one form based on what is entered in to that text box. I then assign that to Name and when the other form is opened I am attempting to have it update to the variable "LabelName" On the other form. I am getting the error that "Value of type 'string' cannot be converted to 'Label'. Can't seem to figure out why
Asked
Active
Viewed 29 times
1
-
Post your code please. – Rich Jan 29 '19 at 18:52
-
Are you trying this with Winforms? WPF? Xamarin? – Jeff R. Jan 31 '19 at 16:23
2 Answers
1
You can simply do the change of label from another class by making the label public and accessing it from wherever you want... But hear seems like you have a problem in assigning a value to the text property. do you sure you did it correct? example :- Form1 form = new Form1(); form.Label1.Text = TextBox1.Text();

Lakshith Nishshanke
- 117
- 7
0
Try This : How to access a form control for another form?
And also it looks like you are trying to assign the string value to the Label itself and that gives the above error. Assign the string to the label.Text instead.

Buddhika Bandara
- 351
- 1
- 11