Jump to content

Recommended Posts

Posted

Hi to all expert, ladies coders and gentlemen coders,

I m quite newbie in this. I just started vb.net not long ago..because i was too crazy bout making an application for my own phone. as for now, i m using .net compact framework to code for my wm6.

My program is easy. the purpose is to edit a .ini file by pointing the correct program path for each line .in the ini file.

in my program, a treeview is enabled. By selecting on the treenode, this will return me the full path of a .exe file/app. Unfortunately, in some folders, there are many subfolders (especially: /window) so it would take some time to show the treenode. so, i have made a label to appear when click to expand the tree and disappear the label before end sub. when, i put it to test, the label is not appearing at all when i click to expand "/window" folder in treeview. so what am i mising here?

 

below is my codemarked in red is the label to appear and disappear)

******************************************************this is configure the mouse click event

Private Sub treeView1_BeforeExpand(ByVal sender As Object, _

ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) _

Handles treeView1.BeforeExpand

plsWaitlbl.Visible = True

'MsgBox("start")

' —-if leaf node then exit—-

 

If e.Node.ImageIndex = icoFile Then Return

 

' —-remove the dummy node and display

 

' the subdirectories and files—-

 

Try

 

e.Node.Nodes.Clear() ' clears all the nodes and...

 

displayChildNodes(e.Node) ' create the nodes again

 

Catch err As Exception

 

MsgBox(err.ToString)

 

End Try

 

' —-change the icon for this node to open—-

 

If e.Node.GetNodeCount(False) > 0 Then

 

e.Node.ImageIndex = icoClose

 

e.Node.SelectedImageIndex = icoOpen

 

End If

plsWaitlbl.Visible = False

'MsgBox("stop")

End Sub

 

*************************************************** i m sure this is show the subdirectories and file

Private Sub displayChildNodes(ByVal parentNode As System.Windows.Forms.TreeNode)

 

Dim FS As New DirectoryInfo(stripExtraSlash _

(parentNode.FullPath))

Dim dirInfo As DirectoryInfo

Dim fileInfo As FileInfo

Try

' —-displays all dirs—-

For Each dirInfo In FS.GetDirectories()

' —-create a new node to be added—-

Dim node As New TreeNode

node.Text = dirInfo.Name ' name of file or dir

node.ImageIndex = icoClose

node.SelectedImageIndex = icoOpen

parentNode.Nodes.Add(node)

' —-add the dummy node—-

node.Nodes.Add("")

Next

 

Catch err As Exception

MsgBox(err.ToString)

End Try

Try

' —display all files—-

 

For Each fileInfo In FS.GetFiles()

If fileInfo.Extension = ".exe" Or fileInfo.Extension = ".lnk" Then

' —-create a new node to be added—-

 

Dim node As New TreeNode

 

node.Text = fileInfo.Name

 

node.ImageIndex = icoFile

 

node.SelectedImageIndex = icoFile

 

parentNode.Nodes.Add(node)

End If

Next

 

Catch err As Exception

MsgBox(err.ToString)

End Try

 

End Sub

***************************************************

Public Function stripExtraSlash(ByVal str As String) As String

' —-strip away the extra "\" for

' subdirectories. e.g. \My documents

 

Dim path As String

If str.Length > 1 And (Mid(str, 1, 1) = "\") Then

path = Mid(str, 2, str.Length - 1)

Else

path = str

End If

Return path

 

End Function

*********************************************************this to set the selected node path to the textbox

Private Sub MenuSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuSelect.Click

pathName = stripExtraSlash(treeView1.SelectedNode.FullPath)

'MsgBox(pathName)

appPathtxt.Text = pathName

 

End Sub

 

Please enlighten me...

 

 

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...