Author Topic: TreeView Control  (Read 2701 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 851
TreeView Control
« on: June 23, 2006, 12:28:15 PM »
Ok, I've started a movement to catalog VBA controls to substitute for ObjectDCL - You see us lispers must finally come over here, with hat humbly in hand, and ask for some help.  I know your first reaction won't be, well, proper - but any help would really be appreciated.  :|

Has anyone used the treeview control in VBA?  I'm getting a syntax error on the following:

Code: [Select]
Dim layerfilters As AcadDictionary
Set layerfilters = ThisDrawing.Layers.GetExtensionDictionary.Item("ACAD_LAYERFILTERS")

For Each entry In layerfilters
TreeView1.Nodes.Add(new treenode, entry.name, entry.name, , ,)
Next

The VB help uses a different syntax:

treeView1.Nodes.Add(New TreeNode(customer2.CustomerName))

but the VBA dynamic help is showing the arg seperated by commas.  Any insight??

Thanks -

jb
James Buzbee
Windows 8

Bob Wahr

  • Guest
Re: TreeView Control
« Reply #1 on: June 23, 2006, 01:11:26 PM »
Try losing your parenthesis, this isn't lisp
Code: [Select]
Dim layerfilters As AcadDictionary
Set layerfilters = ThisDrawing.Layers.GetExtensionDictionary.Item("ACAD_LAYERFILTERS")

For Each entry In layerfilters
TreeView1.Nodes.Add new treenode, entry.name, entry.name, , ,
Next
I haven't done a treeview in a long time and didn't look at this, just noticed that.  The rule for parenthesis, even when intellisense shows them is, right of an equals sign, yes, otherwise, no.

So it would be
set SomeThing = TreeView1.Nodes.Add(new treenode, entry.name, entry.name, , ,)
or
TreeView1.Nodes.Add new treenode, entry.name, entry.name, , ,
not
TreeView1.Nodes.Add(new treenode, entry.name, entry.name, , ,)

hi-tee-hoe

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: TreeView Control
« Reply #2 on: June 23, 2006, 01:19:17 PM »
Thanks Bob - further digging and I caught that but it's still not working:

Code: [Select]

Dim layerfilters As AcadDictionary
Set layerfilters = ThisDrawing.Layers.GetExtensionDictionary.Item("ACAD_LAYERFILTERS")

Set nod0 = TreeView1.Nodes.Add(,,"root","All Layers",,)

For Each entry In layerfilters
Set nodekey = entry.Name
Set nodetext = entry.Name
TreeView1.Nodes.Add ,,nodekey,nodetext,,
Next
James Buzbee
Windows 8

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: TreeView Control
« Reply #3 on: June 23, 2006, 01:28:17 PM »
Try this ...

Also what version of the TreeView control are you trying to use?

Code: [Select]
Dim layerfilters As AcadDictionary
On Error GoTo NoFilters
Set layerfilters = ThisDrawing.layers.GetExtensionDictionary.Item("ACAD_LAYERFILTERS")
NoFilters:
If layerfilters Is Nothing = False Then
 With TreeView1
  For Each Entry In layerfilters
   .Nodes.Add , , Entry.Name, Entry.Name
  Next
 End With
End If
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: TreeView Control
« Reply #4 on: June 23, 2006, 01:51:31 PM »
Keith - that did it! Thanks.

This will help me complete the treeview: next I want to put the appropriate layers as children under the filter nodes.  I'll keep everyone up to date!!

Thanks again Keith and Bob - this forum is great.  ;-)

jb

Have a good weekend!
James Buzbee
Windows 8

Bob Wahr

  • Guest
Re: TreeView Control
« Reply #5 on: June 23, 2006, 01:52:58 PM »
It's only as good as the questions that are asked.



or something