|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
treenode.nodes.add and invokeI have a tree node object with a function that adds nodes to itself
(as it is expanded). I would like to do this on a worker thread, which I do when I create the first level of nodes. However, whilst Treeview has an invoke method, TreeNode does not appear to. Obvioulsy I need to call the invoke method of the TreeNode in order to add the sub nodes on the same thread that the parent node was created on. Where is the invoke method of TreeNode? Take a look at my posting on 'BackgroundWorker' in languages.csharp forum
posted on 4.13.2006. I went through nearly exactly the same problems and got it resolved sweetly in the end -- last posting in the string should be helpful. Jamie Bissett Show quote "Kevin" <kevinherr***@lycos.co.uk> wrote in message news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... >I have a tree node object with a function that adds nodes to itself > (as it is expanded). I would like to do this on a worker thread, which > I do when I create the first level of nodes. > > However, whilst Treeview has an invoke method, TreeNode does not appear > to. Obvioulsy I need to call the invoke method of the TreeNode in > order to add the sub nodes on the same thread that the parent node was > created on. > > Where is the invoke method of TreeNode? > Hi Jamie, thanks for your reply.
I had a look at your thread but i'm not sure how it applies to me. I already have a tree that is 3 levels deep (built earlier on) but once they get down to these lower levels, I need to do a database query in order to add more (lower level) nodes to the node that was expanded. Thanks Kevin Jamie Bissett wrote: Show quote > Take a look at my posting on 'BackgroundWorker' in languages.csharp forum > posted on 4.13.2006. I went through nearly exactly the same problems and > got it resolved sweetly in the end -- last posting in the string should be > helpful. > > Jamie Bissett > "Kevin" <kevinherr***@lycos.co.uk> wrote in message > news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... > >I have a tree node object with a function that adds nodes to itself > > (as it is expanded). I would like to do this on a worker thread, which > > I do when I create the first level of nodes. > > > > However, whilst Treeview has an invoke method, TreeNode does not appear > > to. Obvioulsy I need to call the invoke method of the TreeNode in > > order to add the sub nodes on the same thread that the parent node was > > created on. > > > > Where is the invoke method of TreeNode? > > "Kevin" <kevinherr***@lycos.co.uk> wrote in message Use the one on the TreeView which you can reach from the node.news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... >I have a tree node object with a function that adds nodes to itself > (as it is expanded). I would like to do this on a worker thread, which > I do when I create the first level of nodes. > > However, whilst Treeview has an invoke method, TreeNode does not appear > to. Obvioulsy I need to call the invoke method of the TreeNode in > order to add the sub nodes on the same thread that the parent node was > created on. > > Where is the invoke method of TreeNode? Actually you can use the Invoke on ANY control created by the same thread that created the TreeView (which normally means any control at all). I don't see why you need a thread to do it though - you can do lazy expansion perfectly well without it by just getting one level deeper than is shown expanded. Hi Nick, thanks for your reply.
I'm not sure I understand when you say: "Use the one on the TreeView which you can reach from the node." I know that I can reach the nodes.add method of the treeview, but this will add the nodes at the top of the tree, I need to add them to the node that we are currently dealing with. Also I dont understand what you mean when you say that you can use invoke on any control. This is exaclty what I am saying, there is no invoke method for a treenode. Thanks Kevin Nick Hounsome wrote: Show quote > "Kevin" <kevinherr***@lycos.co.uk> wrote in message > news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... > >I have a tree node object with a function that adds nodes to itself > > (as it is expanded). I would like to do this on a worker thread, which > > I do when I create the first level of nodes. > > > > However, whilst Treeview has an invoke method, TreeNode does not appear > > to. Obvioulsy I need to call the invoke method of the TreeNode in > > order to add the sub nodes on the same thread that the parent node was > > created on. > > > > Where is the invoke method of TreeNode? > > Use the one on the TreeView which you can reach from the node. > > Actually you can use the Invoke on ANY control created by the same thread > that created the TreeView (which normally means any control at all). > > I don't see why you need a thread to do it though - you can do lazy > expansion perfectly well without it by just getting one level deeper than is > shown expanded. "Kevin" <kevinherr***@lycos.co.uk> wrote in message I mean use the Invoke method on the TreeView. The delegate that you supply news:1145350510.764575.326140@z34g2000cwc.googlegroups.com... > Hi Nick, thanks for your reply. > > I'm not sure I understand when you say: > "Use the one on the TreeView which you can reach from the node." > I know that I can reach the nodes.add method of the treeview, but this > will add the nodes at the top of the tree, I need to add them to the > node that we are currently dealing with. does not have to add nodes at the root - it can add them anywhere. Basically, when the delegate gets invoked it will be running in the proper thread to do what it likes to ANY control created on the UI thread (normally this means any control in your app). > The Invoke method on a control is not "for" that control, it is for the UI > Also I dont understand what you mean when you say that you can use > invoke on any control. This is exaclty what I am saying, there is no > invoke method for a treenode. thread that created that control. If it wasn't for the fact that you can have multiple UI threads (which is rarely used) it would be a static method on some UI utility class (I believe that that is how it is done in java) In a typical simple app. Invoke on ANY control will have exactly the same effect. TreeNodes should just be considered as part of the TreeView. Show quote > Thanks > Kevin > > Nick Hounsome wrote: >> "Kevin" <kevinherr***@lycos.co.uk> wrote in message >> news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... >> >I have a tree node object with a function that adds nodes to itself >> > (as it is expanded). I would like to do this on a worker thread, which >> > I do when I create the first level of nodes. >> > >> > However, whilst Treeview has an invoke method, TreeNode does not appear >> > to. Obvioulsy I need to call the invoke method of the TreeNode in >> > order to add the sub nodes on the same thread that the parent node was >> > created on. >> > >> > Where is the invoke method of TreeNode? >> >> Use the one on the TreeView which you can reach from the node. >> >> Actually you can use the Invoke on ANY control created by the same thread >> that created the TreeView (which normally means any control at all). >> >> I don't see why you need a thread to do it though - you can do lazy >> expansion perfectly well without it by just getting one level deeper than >> is >> shown expanded. > Ah! I see, for some reason i thought that if i called treeview.invoke,
I would have to add the nodes to the tree, but of course you are right. Yes, it all becomes clear! It would make more sense to have it as a static method. Thanks for your help, much appreciated. Kevin Nick Hounsome wrote: Show quote > "Kevin" <kevinherr***@lycos.co.uk> wrote in message > news:1145350510.764575.326140@z34g2000cwc.googlegroups.com... > > Hi Nick, thanks for your reply. > > > > I'm not sure I understand when you say: > > "Use the one on the TreeView which you can reach from the node." > > I know that I can reach the nodes.add method of the treeview, but this > > will add the nodes at the top of the tree, I need to add them to the > > node that we are currently dealing with. > > I mean use the Invoke method on the TreeView. The delegate that you supply > does not have to add nodes at the root - it can add them anywhere. > > Basically, when the delegate gets invoked it will be running in the proper > thread to do what it likes to ANY control created on the UI thread (normally > this means any control in your app). > > > > > Also I dont understand what you mean when you say that you can use > > invoke on any control. This is exaclty what I am saying, there is no > > invoke method for a treenode. > > The Invoke method on a control is not "for" that control, it is for the UI > thread that created that control. > > If it wasn't for the fact that you can have multiple UI threads (which is > rarely used) it would be a static method on some UI utility class (I believe > that that is how it is done in java) > > In a typical simple app. Invoke on ANY control will have exactly the same > effect. > > TreeNodes should just be considered as part of the TreeView. > > > Thanks > > Kevin > > > > Nick Hounsome wrote: > >> "Kevin" <kevinherr***@lycos.co.uk> wrote in message > >> news:1144939848.026802.95940@v46g2000cwv.googlegroups.com... > >> >I have a tree node object with a function that adds nodes to itself > >> > (as it is expanded). I would like to do this on a worker thread, which > >> > I do when I create the first level of nodes. > >> > > >> > However, whilst Treeview has an invoke method, TreeNode does not appear > >> > to. Obvioulsy I need to call the invoke method of the TreeNode in > >> > order to add the sub nodes on the same thread that the parent node was > >> > created on. > >> > > >> > Where is the invoke method of TreeNode? > >> > >> Use the one on the TreeView which you can reach from the node. > >> > >> Actually you can use the Invoke on ANY control created by the same thread > >> that created the TreeView (which normally means any control at all). > >> > >> I don't see why you need a thread to do it though - you can do lazy > >> expansion perfectly well without it by just getting one level deeper than > >> is > >> shown expanded. > > |
|||||||||||||||||||||||