线程中修改 DEV TreeList 的问题

fxd1999 2009-06-10 06:16:32
我需要建立一个线程来解析数据,显示到一个TreeList中。
程序如下:
public void hehe()
{
Byte[] aa = new Byte[];
Byte[] receivedata = new Byte[255];
for (i = 0; i < 1000; i++)
{
bb.bulit(aa);
bb.senddata(aa, 18);
if (bb.receive(receivedata) == false)
{
return;
}
else
{
treeList1.BeginUnboundLoad();
string ss=chuli(receivedata);
treeList1.Nodes[0].Nodes[0].SetValue(2,string);
treeList1.EndUnboundLoad();
}
}
调用时 Thread thread = new Thread(new ThreadStart(hehe));
thread.Start();
循环运行几次之后出现 treeList1.EndUnboundLoad();
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

哪位高手帮我看看!!!


...全文
54 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
WuZongBo 2009-06-10
  • 打赏
  • 举报
回复
treeList1.BeginUnboundLoad(); 
string ss=chuli(receivedata);
treeList1.Nodes[0].Nodes[0].SetValue(2,string);
treeList1.EndUnboundLoad();

修改一下
this.Invoke(new MethodInvoke(delegate()
{
treeList1.BeginUnboundLoad();
string ss=chuli(receivedata);
treeList1.Nodes[0].Nodes[0].SetValue(2,string);
treeList1.EndUnboundLoad();
}));

wisejohn 2009-06-10
  • 打赏
  • 举报
回复
看不懂bb,不过应该不是Treelist的问题吧。

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧