Results 1 to 5 of 5

Thread: Raising events on a treeview to update it

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2002
    Posts
    32

    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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You'd call the sub that handles the event (i.e. Treeview1_NodeSelect(me,eventargs.empty))

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2002
    Posts
    32
    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.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    1. Treeview1_BeforeExpand(Treeview1,New TreeviewCancelEventArgs(currentNode, False, TreeViewAction.Unknown)

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2002
    Posts
    32
    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
  •  



Click Here to Expand Forum to Full Width