Propagating events from one Form to another Form in C#

后端 未结 3 2104
心在旅途
心在旅途 2020-12-06 03:14

How can I click a Button in one form and update text in a TextBox in another form?

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 03:35

    Roughly; the one form must have a reference to some underlying object holding the text; this object should fire an event on the update of the text; the TextBox in another form should have a delegate subscribing to that event, which will discover that the underlying text has changed; once the TextBox delegate has been informed, the TextBox should query the underlying object for the new value of the text, and update the TextBox with the new text.

提交回复
热议问题