Changing a form's title
-
OK, so I have my main form 'Form1' and i'm in another class
'controls.cs'
... How can I change the title of my main form'Form1'
from'controls.cs'
?? I tired...Form1 asdf=new Form1; asdf.text="RESPECT THE ENG";
but that dosn't work. How can I do it? /\ |_ E X E GG
-
OK, so I have my main form 'Form1' and i'm in another class
'controls.cs'
... How can I change the title of my main form'Form1'
from'controls.cs'
?? I tired...Form1 asdf=new Form1; asdf.text="RESPECT THE ENG";
but that dosn't work. How can I do it? /\ |_ E X E GG
-
adf.Text
, notasdf.text
."Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi -
well, actually I have this on controls.cs... Form1 asdf = new Form1(); asdf.Text="RESPECT THE ENG"; now... the question i guess... on Form1, how do I call this? /\ |_ E X E GG
Form1 isn't an object. It's a class. asdf is an object (instance of a class). You need to change the text on asdf, not on Form1 and you can't do that unless you have a reference to asdf. You might need to enumerate all the forms until you find the one you want or you could pass a reference of the form to control.cs so that you can manipulate it later.
-
Form1 isn't an object. It's a class. asdf is an object (instance of a class). You need to change the text on asdf, not on Form1 and you can't do that unless you have a reference to asdf. You might need to enumerate all the forms until you find the one you want or you could pass a reference of the form to control.cs so that you can manipulate it later.
try passing the form on the constructor of the control.cs object, and store this in the control object. i.e.
private Form form1; public Control(Form form) { this.form1 = form; }
You should then be able to make calls like form1.Text = "whatever". If that doesn't work quite try public Control(ref Form form).