Click here to Skip to main content
15,905,867 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Problem with Excel Formula... Need some help Pin
Dave Kreskowiak19-Oct-08 18:09
mveDave Kreskowiak19-Oct-08 18:09 
GeneralRe: Problem with Excel Formula... Need some help Pin
Golden Jing19-Oct-08 18:26
Golden Jing19-Oct-08 18:26 
QuestionRuntime instance creation Pin
SelvaShankar16-Oct-08 19:59
SelvaShankar16-Oct-08 19:59 
AnswerRe: Runtime instance creation Pin
Steven J Jowett16-Oct-08 22:44
Steven J Jowett16-Oct-08 22:44 
AnswerRe: Runtime instance creation Pin
Mycroft Holmes17-Oct-08 23:24
professionalMycroft Holmes17-Oct-08 23:24 
GeneralRe: Runtime instance creation Pin
SelvaShankar20-Oct-08 19:06
SelvaShankar20-Oct-08 19:06 
AnswerRe: Runtime instance creation Pin
SelvaShankar31-Oct-08 2:06
SelvaShankar31-Oct-08 2:06 
QuestionPopulate TreeView on demand in VB Pin
Sonhospa16-Oct-08 9:46
Sonhospa16-Oct-08 9:46 
Hi all,

since I found only C#/C++ stuff on my problem, I have to ask you guys for better ways of populating a TreeView control in VB with only a part (!) of the directory structure.

General purpose: I need to simulate a folder explorer which
a) ignores the files in the folder (large number would make it very slow)
That's also the reason why I can't just use FolderBrowserDialog object.
b) only populates subfolders once a parent folder it is expanded (same reason - performance)

By now I have the following solution (which basically works):
Private Sub TreeView_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView.BeforeExpand
   'avoid errors when access denied, i.e. system folders
    On Error Resume Next

    For Each ChildNode As TreeNode In TreeView.SelectedNode.Nodes
        'For Each ChildNode As TreeNode In TreeView.SelectedNode.Nodes
        ' Mehrfaches Füllen vermeiden!
        If ChildNode.Nodes.Count > 0 Then Exit Sub

        Dim di As DirectoryInfo = New DirectoryInfo(ChildNode.FullPath)
        Dim subDirs() As DirectoryInfo = di.GetDirectories("*", SearchOption.TopDirectoryOnly)
        For i = 1 To subDirs.Length
            Dim actSub As New TreeNode(subDirs(i).ToString)
            ChildNode.Nodes.Add(actSub)
            actSub.ImageIndex = Ico_FldClosed
        Next
    Next

End Sub

Problem: It refers to "TreeView.SelectedNode.Nodes", so that the subfolders aren't filled with their subfolders (i.e. grandchildren) in case the user expands the tree by clicking on the "+" symbol without selecting the node first.

Which other property or method could I use? Maybe someone even has a much better solution... I'd really appreciate every good advice!

Thanks
Michael
AnswerRe: Populate TreeView on demand in VB Pin
Dave Kreskowiak16-Oct-08 10:05
mveDave Kreskowiak16-Oct-08 10:05 
NewsRe: Populate TreeView on demand in VB Pin
Sonhospa16-Oct-08 11:24
Sonhospa16-Oct-08 11:24 
GeneralRe: Populate TreeView on demand in VB Pin
Dave Kreskowiak16-Oct-08 12:07
mveDave Kreskowiak16-Oct-08 12:07 
QuestionRe: Populate TreeView on demand in VB Pin
Sonhospa16-Oct-08 12:35
Sonhospa16-Oct-08 12:35 
AnswerRe: Populate TreeView on demand in VB Pin
Dave Kreskowiak16-Oct-08 13:50
mveDave Kreskowiak16-Oct-08 13:50 
GeneralRe: Populate TreeView on demand in VB Pin
Sonhospa16-Oct-08 20:22
Sonhospa16-Oct-08 20:22 
GeneralRe: Populate TreeView on demand in VB Pin
Dave Kreskowiak17-Oct-08 1:54
mveDave Kreskowiak17-Oct-08 1:54 
QuestionProblems Calling A Function Pin
Phantom71516-Oct-08 7:47
Phantom71516-Oct-08 7:47 
AnswerRe: Problems Calling A Function Pin
nlarson1116-Oct-08 7:56
nlarson1116-Oct-08 7:56 
GeneralRe: Problems Calling A Function Pin
Phantom71516-Oct-08 8:01
Phantom71516-Oct-08 8:01 
GeneralRe: Problems Calling A Function Pin
nlarson1116-Oct-08 8:05
nlarson1116-Oct-08 8:05 
AnswerRe: Problems Calling A Function Pin
Caio Kinzel Filho16-Oct-08 8:28
Caio Kinzel Filho16-Oct-08 8:28 
GeneralRe: Problems Calling A Function Pin
Phantom71516-Oct-08 8:44
Phantom71516-Oct-08 8:44 
GeneralRe: Problems Calling A Function Pin
Caio Kinzel Filho16-Oct-08 9:01
Caio Kinzel Filho16-Oct-08 9:01 
GeneralRe: Problems Calling A Function Pin
Phantom71516-Oct-08 9:04
Phantom71516-Oct-08 9:04 
GeneralRe: Problems Calling A Function Pin
Caio Kinzel Filho16-Oct-08 9:15
Caio Kinzel Filho16-Oct-08 9:15 
GeneralRe: Problems Calling A Function Pin
Caio Kinzel Filho16-Oct-08 9:17
Caio Kinzel Filho16-Oct-08 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.