updating a textbox on a form from another class

P

Peted

Hello

i have a textbox on a form1.

I want to pass the name of that textbox as a paramter to another class
(not a form class) and once gotten this paramter i want to update the
textbox on form1 and display text data as data is retrieved via this
other class.

can anyone point or provide some sample code of how this would be done
please


thanks
 
P

pigeonrandle

Hi,
Dont pass the name of the textbox, pass the
System.Windows.Forms.TextBox itself to your other class, then you can
update its .Text property (or any of the other public properties).

HTH,
James Randle.
 
P

pigeonrandle

Hi,
Dont pass the name of the textbox, pass the
System.Windows.Forms.TextBox itself to your other class, then you can
update its .Text property (or any of the other public properties).

HTH,
James Randle.
 
M

Marc Gravell

A more re-usable approach is to expose events and properties on the
class, and have the form respond to those events by updating the
textbox itself. This allows the UI to be re-written (perhaps just
tweaking to a SuperSpiffyTextBox[tm], but perhaps in a radical way -
webforms, wpf, etc) while leaving the non-UI class alone.

Encapsulation, etc...

Marc
 
P

Peted

thanks for the info,

im sorry i dont understand what is meant by the textbox itself, do you
mean a pointer to the control ?

a sample would be appreciated

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top