Acessing a textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thorsten

    #1

    Acessing a textbox

    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
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Acessing a textbox

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "thorsten" <thorsten.moell er@premiere.de> wrote in message
    news:fe2e8db9.0 311200701.41683 4cb@posting.goo gle.com...[color=blue]
    > 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[/color]


    Comment

    Working...