You are on page 1of 1

TV

Hereisthesampletreeviewcode.Trytounderstandthecodeandbuildonit.
Insertatreeviewonyouexcelsheet.Thenameofthetreeviewcontrolherein
thecodeisTreeview1;changethenameinthecodeaccordingly.Pastethiscode
inanygeneralmodule
SubSampleTreeViewCode()
DimtvwAsTreeView
DimndParentAsNode
DimndChildAsNode

Settvw=Sheet1.TreeView1

tvw.Nodes.Clear
SetndParent=tvw.Nodes.Add(,,,"Level1")
SetndChild=tvw.Nodes.Add(ndParent,tvwChild,,"Level2")
ndParent.Expanded=True

Settvw=Nothing
SetndParent=Nothing
SetndChild=Nothing
EndSubThisistheeventtobetracked.Inthedesignmodedoubleclickonthe
treeviewcontroltoandwritethecodeasbelow.
PrivateSubTreeView1_NodeClick(ByValNodeAsMSComctlLib.Node)
MsgBoxNode.Text
EndSub

Page1

You might also like