VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ListView on demand

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
812 Views, 6 Replies

ListView on demand

Hi all,

Hopefully someone can help me. I am trying to add in a listview box on demand - here is what I have


Dim NewControl As Control
Set NewControl = Me.Controls.Add ("MSComctllib.ListView.1", "ListView1", True)

I get an "Invalid Class String" error whenever it gets to this. As far as I can tell from looking at this and help files, I have everything correct.

Thanks in advance

Brent
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Try this

Option Explicit
'require reference to Microsoft Windows Common Controls 6.0(SP6)
'location => C:\WINDOWS\System32\MSCOMCTL.OCX
Private Sub Command1_Click()
Dim lvw As ListView
Dim ctl As Control
Set ctl = Controls.Add("MSComctlLib.ListViewCtrl.2", "ListView1")
With ctl
.Left = 10
.Top = 40
.Height = 120
.Width = 205
.Visible = True
End With
Set lvw = ctl
With lvw
.ColumnHeaders.Add 1, "@", "Counter", 98
.ColumnHeaders.Add 2, "#", "Item", 100
.GridLines = True
.HoverSelection = True
.FullRowSelect = True
.View = lvwReport
End With
Dim i As Integer
Dim lvi As Variant
For i = 0 To 99
Set lvi = lvw.ListItems.Add(, , CStr(i + 1))
lvi.SubItems(1) = "Subitem " & CStr(i + 1)
Next
End Sub

~'J'~
Message 3 of 7
Anonymous
in reply to: Anonymous

Fatty,

You are a deadset Champ!!!! I have been on the net for 4 hours today trying to figure that one out!!

Cheers

Brent
Message 4 of 7
Anonymous
in reply to: Anonymous

Always glad to help
Cheers 🙂

~'J'~
Message 5 of 7
Anonymous
in reply to: Anonymous

wrote in message news:5847562@discussion.autodesk.com...
Try this

Set ctl = Controls.Add("MSComctlLib.ListViewCtrl.2", "ListView1")

cool
where'd you find the progid?
I just thought to look in Oleview and discovered you could see them there,
but previously I didn't have a listing of the correct name for each control.
mark
Message 6 of 7
Anonymous
in reply to: Anonymous

Hi Mark
I've found it in registry here:
HKEY_CLASSES_ROOT\MSComctlLib.ListViewCtrl\CurVer
there are lot of other controls

~'J'~
Message 7 of 7
Anonymous
in reply to: Anonymous

wrote in message news:5847940@discussion.autodesk.com...
Hi Mark
I've found it in registry here:
HKEY_CLASSES_ROOT\MSComctlLib.ListViewCtrl\CurVer
there are lot of other controls

~'J'~

Thanks,
fun stuff
mark
:-)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost