How to change a label from another class? c# windows forms visual studio

后端 未结 4 679
旧巷少年郎
旧巷少年郎 2021-01-28 01:25

I know there are a lot of threads talking about this and believe me I\'ve seen all of them, but I think I\'m a little slow and cant figure out how to do this so here is the thin

4条回答
  •  鱼传尺愫
    2021-01-28 01:53

    Changing the label in that manner is not a good idea and violates some programming paradigms. Generally, the underlying business logic classes are not supposed to directly manipulate the UI.

    The form contains an instance of adi. So, short of passing the form's instance (ie. this) to the adi constructor (or to the paso method), you're kinda sunk.

    Better to use some kind of event that adi can fire when it needs Form1 to change its display.

    http://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx

提交回复
热议问题