zoukankan      html  css  js  c++  java
  • c# usercontrol ,networkcomms3.0 Invoke总结

     1: accordionControl 添加了自定义控件页面 之后,切换到别的页面后,原先打开的页面对象还是存在的没有被销毁,再打开时重新引用即可

      private void accordionControlElement5_Click(object sender, EventArgs e)
            {
                SelectModelShowOnPanel("ad");
            }

        所以需要做一个判断
          if(ad==null) nd = new models.NowDataDemo(_neworkhelper);

     

    2: networkcomms  使用过程中,客户端发送请求需要带返回包的,  并且是时钟不停请求的, 不要使用SendReceiveObject 方法,应为时钟和返回值不同步的话容易出现问题

     客户端发送:
      newTcpConnection.SendObject("ReqCount");
    客户端接收:
    NetworkComms.AppendGlobalIncomingPacketHandler<CountMsgContract>("ResCount", IncomingLineProductCoutRequest);
    ResCount 相当于 路由,接收服务器端发送使用rescount 字符串的数据包

     3: 修改gridview内的值

       this.Invoke(new Action(() =>
                {
                    resmsg.linename = "";
                    resmsg.tiaocount = counttatmsg.TiaoCount;
                    resmsg.firstcount = counttatmsg.FirstCount;
                    resmsg.nextcount = counttatmsg.NextCount;
                }));

    4:gridview 绑定字段模版

      public  class ResReceiveMsg :  INotifyPropertyChanged
        {
             public event PropertyChangedEventHandler PropertyChanged; 
             protected void OnPropertyChanged(string name) 
               {        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }
           private string _linename="";
           private string _tiaocount="";
           private string _firstcount="";
           private string _nextcount="";
           /// <summary>
           ///
           /// </summary>
           public string linename
           {
               get{return _linename;}
               set{_linename=value;OnPropertyChanged("linename");}
           }
           /// <summary>
           ///
           /// </summary>
           public string tiaocount
           {
               get{return _tiaocount;}
               set{_tiaocount=value;OnPropertyChanged("tiaocount");}
           }
           /// <summary>
           ///
           /// </summary>
           public string firstcount
           {
               get{return _firstcount;}
               set{_firstcount=value;OnPropertyChanged("firstcount");}
           }
           /// <summary>
           ///
           /// </summary>
           public string nextcount
           {
               get{return _nextcount;}
               set{_nextcount=value;OnPropertyChanged("nextcount");}
           }
           public ResReceiveMsg(){}
        }

     使用这个模版的好处就是更新了数据源不用刷新控件 ,这个模版已继承了控件更新通知

  • 相关阅读:
    湘潭大学 Hurry Up 三分,求凹函数的最小值问题
    hdu 1166 线段树 单点修改 + 询问区间求和 (线段树模板)
    hdu 1166 树状数组(模板) 更改点值+求区间和
    getline
    poj 1873 The Fortified Forest 凸包+位运算枚举 world final 水题
    C# 代码操作XML(增、删、改)
    C# Socket服务端与客户端通信(包含大文件的断点传输)
    MD5 十六进制加密
    C# 面向对象——多态
    C# 面向对象——继承
  • 原文地址:https://www.cnblogs.com/zuochanzi/p/7909566.html
Copyright © 2011-2022 走看看