• <legend id='SMcTs'><style id='SMcTs'><dir id='SMcTs'><q id='SMcTs'></q></dir></style></legend>
  • <small id='SMcTs'></small><noframes id='SMcTs'>

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

        <tfoot id='SMcTs'></tfoot>
          <bdo id='SMcTs'></bdo><ul id='SMcTs'></ul>

        如何使用委托和事件处理程序进行用户控制

        时间:2023-09-15
      1. <small id='2HKjx'></small><noframes id='2HKjx'>

              <bdo id='2HKjx'></bdo><ul id='2HKjx'></ul>
              <legend id='2HKjx'><style id='2HKjx'><dir id='2HKjx'><q id='2HKjx'></q></dir></style></legend>
                <tbody id='2HKjx'></tbody>

              <i id='2HKjx'><tr id='2HKjx'><dt id='2HKjx'><q id='2HKjx'><span id='2HKjx'><b id='2HKjx'><form id='2HKjx'><ins id='2HKjx'></ins><ul id='2HKjx'></ul><sub id='2HKjx'></sub></form><legend id='2HKjx'></legend><bdo id='2HKjx'><pre id='2HKjx'><center id='2HKjx'></center></pre></bdo></b><th id='2HKjx'></th></span></q></dt></tr></i><div id='2HKjx'><tfoot id='2HKjx'></tfoot><dl id='2HKjx'><fieldset id='2HKjx'></fieldset></dl></div>
                • <tfoot id='2HKjx'></tfoot>
                  本文介绍了如何使用委托和事件处理程序进行用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个包含按钮的用户控件.我在我的 winform 上使用这个控件,它将在从数据库中获取数据后在运行时加载.

                  I have created a user control that contains a button. I am using this control on my winform which will be loaded at run time after fetching data from database.

                  现在我需要在该按钮的 Click 事件中从数据表中删除一行.

                  Now I need to remove a row from a datatable on the Click event of that button.

                  问题是我如何在我的表单中捕获该事件.目前它在该用户控件的 btn 点击事件定义中.

                  The problem is that how do I capture that event in my form. Currently it goes in that user control's btn click event defination.

                  推荐答案

                  您可以通过在用户控件中执行以下操作来创建自己的委托事件:

                  You can create your own delegate event by doing the following within your user control:

                  public event UserControlClickHandler InnerButtonClick;
                  public delegate void UserControlClickHandler (object sender, EventArgs e);
                  

                  您使用以下方法从您的处理程序中调用事件:

                  You call the event from your handler using the following:

                  protected void YourButton_Click(object sender, EventArgs e)
                  {
                     if (this.InnerButtonClick != null)
                     {
                        this.InnerButtonClick(sender, e);
                     }
                  }
                  

                  然后您可以使用以下方法挂钩事件

                  Then you can hook into the event using

                  UserControl.InnerButtonClick+= // Etc.
                  

                  这篇关于如何使用委托和事件处理程序进行用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:创建一个事件来观察变量的变化 下一篇:我可以访问内部类中的外部类对象吗

                  相关文章

                  <tfoot id='VK7Mp'></tfoot><legend id='VK7Mp'><style id='VK7Mp'><dir id='VK7Mp'><q id='VK7Mp'></q></dir></style></legend>

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

                    1. <small id='VK7Mp'></small><noframes id='VK7Mp'>

                        <bdo id='VK7Mp'></bdo><ul id='VK7Mp'></ul>