winForms, referencing to a text box and button from a class
I really need help with referencing from a class to a text box and bu开发者_JS百科tton on a form using the declared names of the boxes and buttons.
example:
say you have a box called testBox that is located in Form1 i am in the testingBox Class and i need to write:
testBox.AppendText("Test Box");
but the syntax error is: "The name 'testBox' does not exist in the current context"
You need to pass the controls to your class using constructor parameters and private fields.
精彩评论