Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP WITH TreeView AND ListView

Status
Not open for further replies.

MoGryph

Programmer
Nov 1, 2000
99
US
I've been wanting to use TreeView and ListView for awhile now, but - I can't do it!

I found this code on the net (not sure where I found it) and it has, as a basic sample for using the controls, the following:

Private Sub Form_Load()
'Declare Variables
Dim mNode As Node
Dim i As Integer
'Populate the list box

List1.AddItem "Node 1"
List1.AddItem "Node 2"
List1.AddItem "Node 3"
'Add the primary node
Set mNode = TreeView1.Nodes.Add()
mNode.Text = "Primary Node"
'Add the nodes from the list box
For i = 0 To List1.ListCount - 1
Set mNode = TreeView1.Nodes.Add(1, tvwChild)
mNode.Text = List1.List(i)
Next i

End Sub


The problem is, List1 doesn't know what "AddItem" is, and TreeView1 doesn't know what a node is! - ie, these methods, or collection references don't show up in the selectable list when I press the '.' after the object's name. AND, I get the following error message when I try to open the form:

"Run-time error '438':
Object doesn't support this property or method.

And Debug drops me on the first List1.AddItem line.

I tried useing this in Access98, and it didn't work. Then I thought this might not be useable in Access, and tried it in Visual Basic 6.0 (Enterprise Edition) (on a different PC), and it still did not work for me.

PLEASE HELP!

MoGryph
- "Don't mess with my crew-cut [8O)"
 
does this help?

Set itmX = ListView1.ListItems.Add(, , "Here is a list", )
Set nodX = TreeView1.Nodes.Add _
(, , , "Here is a Tree",)

 
Omigosh! YES! THANK YOU!

Also, In order to get the Properties and Methods to "Pop-Up" when codeing,
I had to write the following:
Private Form_Load()
Dim nodX As ComctlLib.Node
Dim tv As ComctlLib.TreeView
Dim lv As ComctlLib.ListView
Dim li As ComctlLib.ListItem

Set tv = Me.Tree1
Set nodX = tv.Nodes.Add(, , , "Here is a tree")

Set lv = Me.ListView1
Set li = lv.ListItems.Add
Set li = ListView1.ListItems.Add(, , "Here is a list")
End Sub
 
Ooops, that didn't quite do it. For some reason, after I saved and re-opened, it didn't work. But... I'll work on it and figure it out.
 
Hello;

On Treeview, did you add a reference to the OCX or DLL file in VBA? Look under the tools pull-down menu when a code module is open.

Where I work I wrote an app that uses the treeview control which was found in MSCOMCTL.OCX. Is the same file you use? Did you have any license issues to resolve? We had all kinds of license issues to work around here.

Chell
 
I would like to ask you for your help.
How I have to read the list of choosen items by activeX controle ListView(MSComctlLib) during the multiselect.

Thank you for help.

dirtyX@seznam.cz
 
Dirtyx,

I suggest you start a new thread with this question. just incase I understand you!

to read the list in a multiselect listbox just

dim x as variant
for each x in listbox1.itemsselected
do this
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top