zoukankan      html  css  js  c++  java
  • 事件 委托 简单应用

    子页面向父页面传值。

    子页面代码:

     public delegate void DeleteSelected(string id);
            public event DeleteSelected DoDelete;

            private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                if (DoDelete != null)
                {
                    Image img=sender as Image;
                    DoDelete(img.Tag.ToString().Trim());
                }
               
            }

    父页面代码:

    {

    GetTradeControl getTrade = new GetTradeControl(id, wareName, 1, price);
                            getTrade.DoDelete += new GetTradeControl.DeleteSelected(getTrade_DoDelete);
                            this.grd_get.Children.Add(getTrade);

    }

     void getTrade_DoDelete(string id)
            {
                GetTradeControl gtc_ = null;
                foreach (GetTradeControl gtc in this.grd_get.Children)
                {
                    if (gtc.Id == id)
                    {
                        //this.grd_get.Children.Remove(gtc);
                        gtc_ = gtc;
                    }
                }
                this.grd_get.Children.Remove(gtc_);
            }

  • 相关阅读:
    第十一篇:Mysql系列
    mysql八:ORM框架SQLAlchemy
    mysql七:视图、触发器、事务、存储过程、函数
    mysql六:数据备份、pymysql模块
    工厂方法模式
    execution表达式
    CentOS系统下安装SVN及常用命令
    Spring Boot 表单验证、AOP统一处理请求日志、单元测试
    SSH文件上传代码片段
    JPA 实体映射
  • 原文地址:https://www.cnblogs.com/nidakun/p/3238296.html
Copyright © 2011-2022 走看看