开发者

winForms, referencing to a text box and button from a class

开发者 https://www.devze.com 2023-02-01 21:42 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号