粗浅注释-《扩展GridView》---固定行和列 来源:豆豆技术网 其作者是:webabcd ---补充

二 自定义了委托和事件及事件的处理函数来处理固定行和固定列
   定义一个委托
   public delegate void RowDataBoundCellHandler(object sender, GridViewTableCell gvtc);

   private static readonly object rowDataBoundCellEventKey = new object();
   /// <summary>
   /// RowDataBound事件中的所有单元格
   /// </summary>
   [Category("扩展")]
   声明一个委托型的变量(声明事件RowDataBoundCell)
   public event RowDataBoundCellHandler RowDataBoundCell
   {
       add { Events.AddHandler(rowDataBoundCellEventKey, value); }
       remove { Events.RemoveHandler(rowDataBoundCellEventKey, value); }
   }
   /// <summary>
   /// 触发RowDataBoundCell事件
   /// </summary>
   /// <param name="gvtc"></param>
   建立一个虚方法,包含有触发事件的RowDataBoundCell(object sender, GridViewTableCell gvtc)

   被外调用来触发事件.
   protected virtual void OnRowDataBoundCell(GridViewTableCell gvtc)
   {
       RowDataBoundCellHandler handler = Events[rowDataBoundCellEventKey] as RowDataBoundCellHandler;

       if (handler != null)
       {
          handler(this, gvtc);
       }
   }

   将具体类的具体事件和具体的事件处理程序关联起来(初始化事件的处理) 
   this._sgv.RowDataBoundCell += new MyGridView.RowDataBoundCellHandler(_sgv_RowDataBoundCell);

   void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc)
   在这个处理函数中程序根据新添加的复杂属性FixRowColumn的各项来对相应的表项添加属性,
   这里的这个属性也就是样式
   Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixRow", AttributeValuePosition.Last, ' ');
   Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixCol", AttributeValuePosition.Last, ' ');

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值