|
-
Nov 11th, 2002, 06:11 PM
#1
Thread Starter
Member
Raising events on a treeview to update it
Hey folks,
I have a VB.Net app that does batch renaming, copying and deleting of files according to various input/output paramaters. In the form I have a TreeView object which is populated with the various system devices etc (and behaves like the left pane in Windows Explorer) and a ListView object that reflects the contents (files) of any directory selected in the TreeView.
It all works fine but my problem is that when I've done a rename/copy/delete operation I want to be able to automatically raise a new event to reselect the current node (directory) in the TreeView so it re-reads that directory to get the correct (ie: updated) files.
I tried to use the RaiseEvent method but it appears I can't use this on a TreeView object (or any other windows forms controls) so am at a loss as to how to get the TreeView to automatically update after my file operations have completed.
Can anyone point me in the right direction?
TIA...
Mike.
-
Nov 11th, 2002, 06:33 PM
#2
You'd call the sub that handles the event (i.e. Treeview1_NodeSelect(me,eventargs.empty))
-
Nov 11th, 2002, 07:11 PM
#3
Thread Starter
Member
Thanks... I didn't realise it was that simple! I thought you had to raise an event specifically and just couldn't seem to work out how to do it.
One more thing though: I'm calling the TreeView1_BeforeExpand subroutine which expects a system.object and TreeViewCancelEventArgs...
(eg: Private Sub TreeView1_BeforeExpand(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand)
...any idea how I can pass these paramters through with actual values in them? (ie: not using TreeView1_BeforeExpand(Me, EventArgs.Empty). I've save the current Node when it is first selected (Private currentNode as New TreeNode) so could I then populate the call to BeforeExpand using this node?
Sorry to be so dense on this one - just trying to get to grips with a lot of this stuff!
'preciate the help!
Mike.
-
Nov 12th, 2002, 11:46 AM
#4
Ok usually the treeview sends itself as the sender and for the TreeviewCancelEventArgs you can just make a new one and pass in whatever parameters fit your situation.
VB Code:
Treeview1_BeforeExpand(Treeview1,New TreeviewCancelEventArgs(currentNode, False, TreeViewAction.Unknown)
-
Nov 12th, 2002, 04:20 PM
#5
Thread Starter
Member
Thanks! That now makes much more sense so I should be able to do what I need to update the treeview on the fly.
Cheers,
Mike.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|