1:accordionControl 添加了自定义控件页面 之后,切换到别的页面后,原先打开的页面对象还是存在的没有被销毁,再打开时重新引用即可
private void accordionControlElement5_Click(objectsender, 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 classResReceiveMsg : INotifyPropertyChanged { public eventPropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(stringname) { PropertyChanged?.Invoke(this, newPropertyChangedEventArgs(name)); } private string _linename=""; private string _tiaocount=""; private string _firstcount=""; private string _nextcount=""; /// <summary> /// /// </summary> public stringlinename { get{return_linename;} set{_linename=value;OnPropertyChanged("linename");} } /// <summary> /// /// </summary> public stringtiaocount { get{return_tiaocount;} set{_tiaocount=value;OnPropertyChanged("tiaocount");} } /// <summary> /// /// </summary> public stringfirstcount { get{return_firstcount;} set{_firstcount=value;OnPropertyChanged("firstcount");} } /// <summary> /// /// </summary> public stringnextcount { get{return_nextcount;} set{_nextcount=value;OnPropertyChanged("nextcount");} } publicResReceiveMsg(){} }
使用这个模版的好处就是更新了数据源不用刷新控件 ,这个模版已继承了控件更新通知