<legend id='DfPcq'><style id='DfPcq'><dir id='DfPcq'><q id='DfPcq'></q></dir></style></legend>

<small id='DfPcq'></small><noframes id='DfPcq'>

      <tfoot id='DfPcq'></tfoot>
      <i id='DfPcq'><tr id='DfPcq'><dt id='DfPcq'><q id='DfPcq'><span id='DfPcq'><b id='DfPcq'><form id='DfPcq'><ins id='DfPcq'></ins><ul id='DfPcq'></ul><sub id='DfPcq'></sub></form><legend id='DfPcq'></legend><bdo id='DfPcq'><pre id='DfPcq'><center id='DfPcq'></center></pre></bdo></b><th id='DfPcq'></th></span></q></dt></tr></i><div id='DfPcq'><tfoot id='DfPcq'></tfoot><dl id='DfPcq'><fieldset id='DfPcq'></fieldset></dl></div>

      • <bdo id='DfPcq'></bdo><ul id='DfPcq'></ul>
    1. 在 C# 中将事件从一个表单传播到另一个表单

      Propagating events from one Form to another Form in C#(在 C# 中将事件从一个表单传播到另一个表单)

          <tbody id='4QM4t'></tbody>

        1. <small id='4QM4t'></small><noframes id='4QM4t'>

              <bdo id='4QM4t'></bdo><ul id='4QM4t'></ul>
              <i id='4QM4t'><tr id='4QM4t'><dt id='4QM4t'><q id='4QM4t'><span id='4QM4t'><b id='4QM4t'><form id='4QM4t'><ins id='4QM4t'></ins><ul id='4QM4t'></ul><sub id='4QM4t'></sub></form><legend id='4QM4t'></legend><bdo id='4QM4t'><pre id='4QM4t'><center id='4QM4t'></center></pre></bdo></b><th id='4QM4t'></th></span></q></dt></tr></i><div id='4QM4t'><tfoot id='4QM4t'></tfoot><dl id='4QM4t'><fieldset id='4QM4t'></fieldset></dl></div>

              • <legend id='4QM4t'><style id='4QM4t'><dir id='4QM4t'><q id='4QM4t'></q></dir></style></legend><tfoot id='4QM4t'></tfoot>
                本文介绍了在 C# 中将事件从一个表单传播到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在一个表单中单击按钮并在另一个表单中更新 TextBox 中的文本?

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

                推荐答案

                如果您尝试使用 WinForms,您可以在您的子"表单中实现自定义事件.当单击子"表单中的按钮时,您可以触发该事件.

                If you're attempting to use WinForms, you can implement a custom event in your "child" form. You could have that event fire when the button in your "child" form was clicked.

                然后,您的父"表单将监听该事件并处理它自己的 TextBox 更新.

                Your "parent" form would then listen for the event and handle it's own TextBox update.

                public class ChildForm : Form
                {
                    public delegate SomeEventHandler(object sender, EventArgs e);
                    public event SomeEventHandler SomeEvent;
                
                    // Your code here
                }
                
                public class ParentForm : Form
                {
                    ChildForm child = new ChildForm();
                    child.SomeEvent += new EventHandler(this.HandleSomeEvent);
                
                    public void HandleSomeEvent(object sender, EventArgs e)
                    {
                        this.someTextBox.Text = "Whatever Text You Want...";
                    }
                }
                

                这篇关于在 C# 中将事件从一个表单传播到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)

                      <tbody id='Cj2UG'></tbody>
                      <legend id='Cj2UG'><style id='Cj2UG'><dir id='Cj2UG'><q id='Cj2UG'></q></dir></style></legend>

                      <small id='Cj2UG'></small><noframes id='Cj2UG'>

                      • <bdo id='Cj2UG'></bdo><ul id='Cj2UG'></ul>

                        1. <i id='Cj2UG'><tr id='Cj2UG'><dt id='Cj2UG'><q id='Cj2UG'><span id='Cj2UG'><b id='Cj2UG'><form id='Cj2UG'><ins id='Cj2UG'></ins><ul id='Cj2UG'></ul><sub id='Cj2UG'></sub></form><legend id='Cj2UG'></legend><bdo id='Cj2UG'><pre id='Cj2UG'><center id='Cj2UG'></center></pre></bdo></b><th id='Cj2UG'></th></span></q></dt></tr></i><div id='Cj2UG'><tfoot id='Cj2UG'></tfoot><dl id='Cj2UG'><fieldset id='Cj2UG'></fieldset></dl></div>

                          <tfoot id='Cj2UG'></tfoot>