vb.net - unwanted treeview node duplicating at the end of list -
i have following code cant seem find reason (nor solution) why parent node keeps appearing @ end of list duplicate?
imports system.io public class form1 private sub form1_load(sender object, e eventargs) handles mybase.load dim di new io.directoryinfo("c:\la") dim diar1 io.fileinfo() = di.getfiles() dim dra io.fileinfo each dra in diar1 'dim sr streamreader = new streamreader(dra.fullname) if system.io.path.getextension(dra.name).tolower() = ".xls" treeview1.nodes.add("offerts") treeview1.nodes(0).nodes.add(dra.name) end if next end sub end class
on first .xls file finds, creates "offerts" node in root of tree, , creates node filename under "offerts".
on subsequent .xls files, creates another "offerts" node in root, , creates node filename under first node (the first "offerts" node created).
so think want create "offerts" node once, @ root, treeview1.nodes.add("offerts")
should not run each time finds .xls file. replacing line like:
if treeview1.nodes.count = 0 treeview1.nodes.add("offerts")
will work, given scenario. if treeview has nodes, you'll have modify logic.
Comments
Post a Comment