Acessing a textbox

  • Thread starter Thread starter thorsten
  • Start date Start date
T

thorsten

Hi,

i have one file with all the UI stuff and one file with some classes
doing several things. One of this classes should handle errors and
update a textbox in the ui.

How do i access this textbox when my UI is in a class called
MainForm??

Thanks for any ideas!

Cheers

Thorsten
 
Thorsten

What you have to do is expose the textbox publically (as you would on
any other object contained by a class). You can do this through a method,
or through a property, etc, etc. Then, you need to pass a reference to your
form around to the classes, and then the classes can set the property using
the reference to the form.

However, this is not the best design. If anything, you should expose a
method on your form that will set the text, and then pass a reference to the
form around and call the method on the form. Or, even better, have your
objects fire events which the form subscribes to, and have the form update
itself.

Hope this helps.
 
Back
Top