how do we give you answer , show your codes
解决方案 »
- 没分数求帮助 关于C# 登录窗口
- 不显示删除回复显示所有回复显示星级回复显示得分回复 请问怎么接收返回的XML文档
- 怎样延后代码执行?
- 关于datagridview里checkbox列事件的一个很严重的问题.
- c#快捷键显示和隐藏窗体
- 很简单的问题.关于窗口的.
- 用批复日期>= #"+dt1.Value.ToShortDateString ()+"# and 批复日期<= #"+ dt2.Value.ToShortDateString () +"# 查询Access数据库,为什
- 大家看看这个错误是什么原因?
- VS2005打开项目文件后假死了
- excel导入到dataset中数据缺损
- 用哪个函数可以得到本机的名称
- 大虾们帮帮忙,谁会用dotunit?
{
try
{
string[,] mstrRecvInfo = Frm_Sms.smsControl1.GetSimInfo();
if (mstrRecvInfo[i,1].Substring(1,2) == "A1")
{
this.BindTreeMMCS();
} }
catch(Exception AppErr)
{
MessageBox.Show("系统错误:OnRecvMsg" + AppErr.Message); }
}
下面是重新生成树节点: private void BindTreeMMCS()
{//01
try
{
DataSet dsMonitor = new DataSet();
System.Data.DataTable dtMonitor = new DataTable();
dsMonitor = clsWSGetData.GetMonitorData();
if (dsMonitor == null ) return ;
dtMonitor = dsMonitor.Tables[0];
if (dtMonitor.Rows.Count <= 0) return ; this.Tv_CoalMineInfo.Nodes.Clear(); if (dtMonitor.Rows.Count > 0 )
{//02
foreach(DataRow dr2 in dtMonitor.Rows)
{//03
if ((dr2[0].ToString().Trim().Length == 6))
{//04
TreeGroupNode n2 = new TreeGroupNode(); n2.Text = dr2[1].ToString().Trim();
n2.Value = dr2[0].ToString().Trim();
foreach(DataRow dr3 in dtMonitor.Rows)
{//05
if ((dr3[0].ToString().Trim().Length == 9) && (dr3[0].ToString().Trim().Substring(0,6) == dr2[0].ToString().Trim()) )
{//06
TreeGroupNode n3 = new TreeGroupNode();
n3.Text = dr3[1].ToString().Trim();
n3.Value = dr3[0].ToString().Trim();
foreach(DataRow dr4 in dtMonitor.Rows)
{
if ((dr4[0].ToString().Trim().Length ==12) && (dr4[0].ToString().Trim().Substring(0,9) == dr3[0].ToString().Trim()) )
{
TreeGroupNode n4= new TreeGroupNode();
n4.Text = dr4[1].ToString().Trim();
n4.Value = dr4[0].ToString().Trim();
foreach(DataRow dr5 in dtMonitor.Rows)
{
if ((dr5[0].ToString().Trim().Length == 15) && (dr5[0].ToString().Trim().Substring(0,12) == dr4[0].ToString().Trim()) )
{
TreeGroupNode n5 = new TreeGroupNode();
n5.Text = dr5[1].ToString().Trim();
n5.Value = dr5[0].ToString().Trim();
foreach(DataRow dr6 in dtMonitor.Rows)
{
if ((dr6[0].ToString().Trim().Length == 18) && (dr6[0].ToString().Trim().Substring(0,15) == dr5[0].ToString().Trim()) )
{
TreeGroupNode n6 = new TreeGroupNode();
n6.Text = dr6[1].ToString().Trim();
n6.Value = dr6[0].ToString().Trim();
DataSet dsMine = new DataSet();
dsMine = this.clsWSGetData.GetMineByMonitor(n6.Value.ToString().Trim());
if(dsMine != null)
{
if (dsMine.Tables[0].Rows.Count > 0)
{
foreach(DataRow dr7 in dsMine.Tables[0].Rows)
{
TreeGroupNode n7 = new TreeGroupNode();
n7.Text = dr7[1].ToString().Trim();
n7.Value ="W" + dr7[0].ToString().Trim();
DataSet dsChild = new DataSet();
dsChild = this.clsWSGetData.GetChildByMine(dr7[0].ToString().Trim());
if (dsChild != null)
{
if (dsChild.Tables[0].Rows.Count > 0)
{
foreach(DataRow dr8 in dsChild.Tables[0].Rows)
{
TreeGroupNode n8 = new TreeGroupNode();
n8.Text = dr8[2].ToString().Trim();
n8.Value ="C" + dr8[1].ToString().Trim();
DataSet dsSensor = new DataSet();
dsSensor = this.clsWSGetData.GetSensorByMineChild(dr7[0].ToString().Trim(),dr8[1].ToString().Trim());
if (dsSensor != null)
{
if (dsSensor.Tables[0].Rows.Count >0)
{
foreach(DataRow dr9 in dsSensor.Tables[0].Rows)
{
TreeGroupNode n9 = new TreeGroupNode();
n9.Text = "传感器"+dr9[2].ToString().Trim();
n9.Value ="S" + dr9[2].ToString().Trim();
n8.Nodes.Add(n9);
}
}
}
n7.Nodes.Add(n8);
}
}
}
n6.Nodes.Add(n7);
}
}
} n5.Nodes.Add(n6);
}
}
n4.Nodes.Add(n5);
}
}
n3.Nodes.Add(n4);
}
}
n2.Nodes.Add(n3);
}//06
}//05
this.Tv_CoalMineInfo.Nodes.Add(n2);
}//04
}//03
this.Tv_CoalMineInfo.ExpandAll(); }//02
}
catch
{
}
}//01
执行到this.Tv_CoalMineInfo.Nodes.Add(n2);语句时跳出
把生成好的节点载入树控件时出现错误:在该控件上执行的操作正被错误的线程调用。必须使用Control.Invoke或Control.BeginInvoke封送到正确的线程才能执行此操作。
this.Tv_CoalMineInfo.Nodes.Add(n2);
CoalMineInfo是树控件
需定义一个委托,
比如异步,
this.listView1.BeginInvoke(new UpdateListViewHandler(MessageInfoShow),new object[]{e.PingResult});
http://blog.csdn.net/zhzuo/archive/2004/07/08/37262.aspx