Control access from other classes
-
I was interested in how to accomplish this: Say I have a textbox on form1.cs. I would like to print messages into that textbox from other class files such as work.cs I am sure this is very simple and I am an idiot hehehehe Can someone help me out?
-
I was interested in how to accomplish this: Say I have a textbox on form1.cs. I would like to print messages into that textbox from other class files such as work.cs I am sure this is very simple and I am an idiot hehehehe Can someone help me out?
Just make a public property in the other class for the text of the text box, and within it you will be able to get the value of it like :
//work.cs class Work { TextBox t = new TextBox(); public string TextT { get{return this.t.Text;} } } //form1.cs class form1 { TextBox holder = new TextBox(); holder.Text = Work.TextT; }
But this must be have the same namespace or in the same directory ,or at least make a reference to the dll that contains that class Work . -
Just make a public property in the other class for the text of the text box, and within it you will be able to get the value of it like :
//work.cs class Work { TextBox t = new TextBox(); public string TextT { get{return this.t.Text;} } } //form1.cs class form1 { TextBox holder = new TextBox(); holder.Text = Work.TextT; }
But this must be have the same namespace or in the same directory ,or at least make a reference to the dll that contains that class Work .Thanks for the reply! I have attached a zip with a sample project which (I think) illustrates my problem. If you have some time to spare, could you take a look at it? Thanks and sorry for my pretty rookie problems... http://www.djnokturnal.com/downloads/TextBoxes.zip[^]