i have been on application that consist of two forms
1st Form = Primary Form 2nd Form = Secondary Form ( Consists of three Track bars with names R, G ,B)
i m trying for few days to change the Background Color of Primary form simultaneously , whenever i move the trackbar in Secondary form
Problem: i used .Show() to get hold of Primary form, and from secondary form ,i m able to change color of Primary Form but the Problem is that .Show() pops up the new primary form every time i move the trackbar
is there a way through which i can send trackbar values to Primary form and can change the Background Color of Primary Form ,
PJ MartinsRank #2,548 · 548 reputationPosted Jun 17, 2010, 7:56 AM EDT
0
You're problem is that you are creating a new instance of Form1 each time instead of accessing the parent Form1. You can create a property on your Form2 which contains the parent Form1 and then simply change it's color.
Property in Form2:
public Form MyParent { get; set; } Now in Form1 when you call Form2 you'd have
Form2 frm = new Form2(); frm.MyParent = this; frm.Show(); In your UpdateMe() you can now change frm.BackColor to this.MyParent.BackColor and remove any Form1 frm = new Form1();
PJ MartinsRank #2,548 · 548 reputationPosted Jun 17, 2010, 7:56 AM EDT
Property in Form2:
public Form MyParent { get; set; }
Now in Form1 when you call Form2 you'd have
Form2 frm = new Form2();
frm.MyParent = this;
frm.Show();
In your UpdateMe() you can now change frm.BackColor to this.MyParent.BackColor and remove any Form1 frm = new Form1();