Results 1 to 5 of 5

Thread: [RESOLVED] Treeview.ExpandAll - When is it done?

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Treeview.ExpandAll - When is it done?

    Ola,

    I have loaded a treeview with files and folders. When I click on a folder which has a lot of subfolders and files this can take a while. Which event do I need to use to show a messagbox that the "expanding" is done? The is the same when I use Treeview.ExpandAll().

    Thanks in advance.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Treeview.ExpandAll - When is it done?

    Are you talking about the AfterExpand event?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Treeview.ExpandAll - When is it done?

    Thanks, but no.
    Example:
    - Treeview is loaded with files and folders;
    - When I click on a [+] to expand a folder I want to show: "expanding folder" on a label and when it is done expanding the folder: "done".


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Treeview.ExpandAll - When is it done?

    Quote Originally Posted by Radjesh Klauke View Post
    Thanks, but no.
    Example:
    - Treeview is loaded with files and folders;
    - When I click on a [+] to expand a folder I want to show: "expanding folder" on a label and when it is done expanding the folder: "done".
    Actually, yes. You are looking for the BeforeExpand and AfterExpand events. This is a simulation of expanding a TreeView that takes time to process:

    vb.net Code:
    1. Public Class Form1
    2.  
    3.     '//fields
    4.     Private previousText As String
    5.  
    6.     '//event handlers
    7.     Private Sub TreeView1_AfterExpand(ByVal sender As Object, _
    8.                                       ByVal e As TreeViewEventArgs) _
    9.                                       Handles TreeView1.AfterExpand
    10.         e.Node.Text = Me.previousText
    11.  
    12.         '//you could do this, although you might just
    13.         '//want to set the text back as it is annoying
    14.  
    15.         '//MessageBox.Show("Done")
    16.     End Sub
    17.  
    18.     Private Sub TreeView1_BeforeExpand(ByVal sender As Object, _
    19.                                        ByVal e As TreeViewCancelEventArgs) _
    20.                                        Handles TreeView1.BeforeExpand
    21.         Me.previousText = e.Node.Text
    22.         e.Node.Text = "Expanding..."
    23.         Application.DoEvents()
    24.         Threading.Thread.Sleep(750)
    25.     End Sub
    26.  
    27.     Private Sub Button1_Click(ByVal sender As System.Object, _
    28.                               ByVal e As System.EventArgs) _
    29.                               Handles Button1.Click
    30.         '//make sure you add some nodes
    31.         Me.TreeView1.Nodes(0).ExpandAll()
    32.     End Sub
    33.  
    34. End Class

  5. #5

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Treeview.ExpandAll - When is it done?

    Thanks ForumAccount. +REP


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

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