如何通过线程将节点添加到TreeView中? [英] How to add nodes into TreeView via Threads?

查看:55
本文介绍了如何通过线程将节点添加到TreeView中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是动态创建的TreeView,能够使用按钮更新/添加节点。

问题是,如果我是使用线程。


任何想法和建议?

Hi,

I am dynamically created TreeView and able to update/add nodes using button.
The problem is nothing is being done if I was using threads.

Any ideas and suggestion?

推荐答案

请记住,您不应该访问UI线程直接。你将需要在UI线程中创建一个AddNode方法,然后从你的线程中调用

.


-

鲍勃鲍威尔[MVP]

Visual C#,System.Drawing


Ramuseco Limited .NET咨询
http://www.ramuseco.com


在Windows窗体提示和技巧中查找优秀的Windows窗体文章
http:// www.bobpowell.net/tipstricks.htm


用GDI + FAQ回答那些GDI +问题
http://www.bobpowell.net/faqmain.htm


所有新文章提供C#和VB.NET中的代码。

订阅提供的RSS源,绝不会错过任何新文章。


EOS <无**** @ nospam.org>在留言中写道

news:ew ************** @ TK2MSFTNGP12.phx.gbl ...
Remember that you should not access data on the UI thread directly. You''ll
need to create an AddNode method in the UI thread and then invoke that from
your thread.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EOS" <no****@nospam.org> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...

我动态创建了TreeView,并能够使用
按钮更新/添加节点。如果我使用线程,问题是没有做任何事情。

任何想法和建议?
Hi,

I am dynamically created TreeView and able to update/add nodes using
button. The problem is nothing is being done if I was using threads.

Any ideas and suggestion?



我实际上使用类似的方法PictureBox的工作原理......


听起来像唯一的方法就是UI中的AddNote?但问题是我只收到线程上的

数据,然后我知道要添加到TreeView中的内容。


希望我的解释清楚明了...


Bob Powell [MVP]" < bob@_spamkiller_bobpowell.net>在消息中写道

新闻:uI ************** @ TK2MSFTNGP15.phx.gbl ...
I actually use similar method of PictureBox and it works...

Sound like the only way is the AddNote in UI? But problem I only receive the
data on threads, then I know what to be added into the TreeView.

Hope my explanaition is clear enought...

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:uI**************@TK2MSFTNGP15.phx.gbl...
记住你不应该直接访问UI线程上的数据。你需要在UI线程中创建一个AddNode方法,然后从你的线程中调用它。

- 鲍勃鲍威尔[MVP]
Visual C#,System.Drawing

Ramuseco Limited .NET咨询
http://www.ramuseco.com

在Windows窗体提示和技巧中找到优秀的Windows窗体文章
http://www.bobpowell.net/tipstricks.htm

用GDI +回答那些GDI +问题常见问题
http://www.bobpowell.net/faqmain.htm

所有新文章都提供C#和VB.NET代码。
订阅提供的RSS源,绝不会错过任何新文章。


EOS <无**** @ nospam.org>在消息中写道
新闻:ew ************** @ TK2MSFTNGP12.phx.gbl ...
Remember that you should not access data on the UI thread directly. You''ll
need to create an AddNode method in the UI thread and then invoke that
from your thread.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EOS" <no****@nospam.org> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...

我动态创建了TreeView,并能够使用
按钮更新/添加节点。如果我使用线程,问题是没有做任何事情。

任何想法和建议?
Hi,

I am dynamically created TreeView and able to update/add nodes using
button. The problem is nothing is being done if I was using threads.

Any ideas and suggestion?




EOS写道:
我实际上使用PictureBox的类似方法,它的工作原理...


这并不意味着它应该工作,它总会有效,甚至可以在所有情况下都能正常工作。

听起来像唯一的方法是UI中的AddNote?但问题是我只收到线程上的数据,然后我知道要添加到TreeView中的内容。

希望我的解释很清楚......
I actually use similar method of PictureBox and it works...
That doesn''t mean it should work, that it will always work, or even
that it currently works in all situations.
Sound like the only way is the AddNote in UI? But problem I only receive the
data on threads, then I know what to be added into the TreeView.

Hope my explanaition is clear enought...




请参阅 http:// www.pobox.com/~skeet/csharp/t...winforms.shtml

Jon



See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

Jon

这篇关于如何通过线程将节点添加到TreeView中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆