c# Accessing WinForm control properties from another class

后端 未结 4 611
难免孤独
难免孤独 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:09

    This looks like a big time code smell :). You would need an instance of Form1 inside of Class1 in order to PBUpdate. Something tells me what you are doing is just not right.

    Explain what you are trying to do and we can help. Otherwise there is no way to access PBUpdate unless you either made it a static function where you could call it like Form1.PBUpdate() or you had an instance of Form1 within your class Class1

提交回复
热议问题