TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Beeman
NA
15
0
How to change a label on Form1 from Form2?
Jul 25 2008 3:30 PM
I am having trouble changing a label on a different form. Can anyone tell me what I'm doing wrong here? Thanks.
On Form 1, I have the following, where label1 is defined in Form1.Designer:
public string Lbl
{
get {
return label1.Text;
}
set {
label1.Text = value;
MessageBox.Show(label1.Text); //Debug: Value here shows correctly but label does not actually change on Form
}
}
On Form2 I have this:
void setLabelInForm1()
{
Form1 frm1 = new Form1();
frm1.Lbl = "LOADED";
}
private void button1_Click_1(object sender, EventArgs e)
{
........................
setLabelInForm1();
.......................
}
Reply
Answers (
3
)
Cross- thread operation not valid
Loop, Timer & datagridView