Thread: Help

  1. #1
    Registered User
    Join Date
    Sep 2001

    Unhappy Help

    Hi, sorry for my stupid question about windows form application again:

    There are two *.cs files in one solution, one is where the main form and one button and public textbox initialized and created. The other one is where a function used to change the textbox.text on the main form.

    In the 2nd *.cs file:

    private Form1 form = new Form1()

    public void test()
    form.textbox.Text = "this is from another class";


    in the Form1.cs, I created an instance of 2nd*.cs and called the function by button click event, but the textbox.text wasn't changed at all, what shall I do then?

    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    This is a design error in the first place. No member variable should ever be public. The function you created in the second file should have been a public member function of your form class which operates on this forms private textbox. You can then call this method on your created form object.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed