updating a textbox on a form from another class

  • Thread starter Thread starter Peted
  • Start date Start date
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
 
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.
 
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.
 
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
 
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
 
Back
Top