adding a node to treeview from another thread 
Author Message
 adding a node to treeview from another thread

I am trying to add a node to a treeview from another thread in VB.net
I know I should use the invoke method but I can't find a good example.
My code is:
Treeview1.Nodes.Add(New TreeNode("testing)))
Can someone give me a simple example ?
Thanks




Tue, 03 Aug 2004 21:35:17 GMT  
 adding a node to treeview from another thread

Quote:
> I am trying to add a node to a treeview from another thread in VB.net
> I know I should use the invoke method but I can't find a good example.
> My code is:
> Treeview1.Nodes.Add(New TreeNode("testing)))
> Can someone give me a simple example ?
> Thanks

http://gotdotnet.com/quickstart/howto/doc/WinForms/WinFormsThreadMarshal
ling.aspx

--
Patrick Steele
Microsoft .NET MVP



Tue, 03 Aug 2004 22:04:36 GMT  
 adding a node to treeview from another thread
Thanks for the great example.
If my function (UpdateProgress) gets 2 string argumenets, how do I call it ?
Your example invoke a function without arguments.

code:
Dim mi As New MethodInvoker(AddressOf Me.UpdateProgress)
Me.BeginInvoke(mi)

Private Sub UpdateProgress(string1 as string, string2 as string )

Thanks


Quote:
> > I am trying to add a node to a treeview from another thread in VB.net
> > I know I should use the invoke method but I can't find a good example.
> > My code is:
> > Treeview1.Nodes.Add(New TreeNode("testing)))
> > Can someone give me a simple example ?
> > Thanks

> http://gotdotnet.com/quickstart/howto/doc/WinForms/WinFormsThreadMarshal
> ling.aspx

> --
> Patrick Steele
> Microsoft .NET MVP



Tue, 03 Aug 2004 23:26:24 GMT  
 adding a node to treeview from another thread

Quote:
> Thanks for the great example.
> If my function (UpdateProgress) gets 2 string argumenets, how do I call it ?
> Your example invoke a function without arguments.

> code:
> Dim mi As New MethodInvoker(AddressOf Me.UpdateProgress)
> Me.BeginInvoke(mi)

> Private Sub UpdateProgress(string1 as string, string2 as string )

Use the second form of BeginInvoke which accepts an array of Objects to
pass as parameters:

Me.BeginInvoke(mi, New Object() {string1,string2})

--
Patrick Steele
Microsoft .NET MVP



Tue, 03 Aug 2004 23:30:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Adding a node to a treeview from a different thread

2. Adding TreeView nodes in separate thread

3. Add a node to treeview under thread

4. treeview node count not incrementing when adding new nodes

5. Adding nodes to Treeview

6. Adding Nodes to TreeView and XML files

7. Recursive TreeView (adding extra nodes)

8. TreeView Add Node

9. Adding Treeview nodes

10. Add treeview node

11. Treeview, scroll to newly added/selected nodes?

12. TREEVIEW ADD NODE

 

 
Powered by phpBB® Forum Software