Help

This is a discussion on Help within the C# Programming forums, part of the General Programming Boards category; Hi, sorry for my stupid question about windows form application again: There are two *.cs files in one solution, one ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    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?

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

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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.
    hth
    -nv

    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21