[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.
Re: Treeview.ExpandAll - When is it done?
Are you talking about the AfterExpand event?
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".
Re: Treeview.ExpandAll - When is it done?
Quote:
Originally Posted by
Radjesh Klauke
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:
Public Class Form1
'//fields
Private previousText As String
'//event handlers
Private Sub TreeView1_AfterExpand(ByVal sender As Object, _
ByVal e As TreeViewEventArgs) _
Handles TreeView1.AfterExpand
e.Node.Text = Me.previousText
'//you could do this, although you might just
'//want to set the text back as it is annoying
'//MessageBox.Show("Done")
End Sub
Private Sub TreeView1_BeforeExpand(ByVal sender As Object, _
ByVal e As TreeViewCancelEventArgs) _
Handles TreeView1.BeforeExpand
Me.previousText = e.Node.Text
e.Node.Text = "Expanding..."
Application.DoEvents()
Threading.Thread.Sleep(750)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
'//make sure you add some nodes
Me.TreeView1.Nodes(0).ExpandAll()
End Sub
End Class
Re: Treeview.ExpandAll - When is it done?
Thanks ForumAccount. +REP