Sry if this seems weak but im at work not at home so im going off complete memeory. but try call the form name first then (.) find the backcolor if that doesnt work, try setting the modifere for the FORM to public and then try
If you have created the treewiew in a GUI/Windows form intereface then just go to itz properties and there will be a section title "Modifer" set that to public and that allows other forms/class to call itz properties. You have to make sure any properties or object frields such at txt box, picture boxes on the form also have they modifers set to public if you want to acess them specifically.
How can I access the BackColor property of a control stored in another form?
K. Maheswar Reddy
then acces it simple
just some example:
public class From2
{
.....
public TextBox TBox;
....
}
// somewhere in another form
Form2 b=new Form2();
b.TBox.BackColor=....
if you are using Visua Studio.. and use the Designer.. check the Form2.Designer.cs
Frediano
Nver a good idea to expose the textbox as public.Always use a get-only property such as
private TextBox m_txtBox;
public TextBox TxtBox
{
get{ return m_txtBox;}
}
and then use the color.Also consider carefully if you need to expose the entire textbox or just use the Color.
Raj1979
Thanks guys but I really don't understand. I am a beginner.
I tried the following:
lblHello.Font = frmMain.treeview1.Font;
After changing the treeview propery to public:
public System.Windows.Forms.TreeView treeview1;
But it's not working :(
Bonquest Technologies
call the form
For Instance,
frmMonters has a backcolor of Blue
and you want the form frmMain to get that color
EXAMPLE of code
Color temp = frmMonsters.Backcolor
Sry if this seems weak but im at work not at home so im going off complete memeory. but try call the form name first then (.) find the backcolor if that doesnt work, try setting the modifere for the FORM to public and then try
Yum
Thanks guys. I did it in both ways. But I like more the first way (changing the modifier).
Can you tell me the disadvantage of this And the advantages of using a method
TIA.
Richard Thomas
StievieD
man i just gaved him an idea.. he can make propreties of course .. but thats like putting the cherry on the cake