c# Accessing WinForm control properties from another class

后端 未结 4 641
难免孤独
难免孤独 2021-01-22 02:58

How does one access WinForm controls such as ProgressBar properties from another class?

Please see my code below. I know this might not be the best option

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 03:16

    You can change the access modifiers of the progress bar from private to Internal or public , you can do this operation from properties pane .

    Properties pane

    Keep in mind that you have to pass to the second class the instance of the form and then you can change the value of the progress bar directly from the second class.

    However is a tricky solution, the best should be keep the presentation layer implementation separated and work with an event.

提交回复
热议问题