Author Topic: Add Listview control at runtime  (Read 5611 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Add Listview control at runtime
« on: February 13, 2008, 04:07:01 PM »
I've got a DVB that I'm working on that I would like to use the Listview control.  The problem is this: the number of listview controls depends on the number of particular objects in the drawing.  I've tried Controls.Add("Forms.Listview.1") but that only gave me an 'Invalid class string' error message.

Any takers?   :-)

Atook

  • Swamp Rat
  • Posts: 994
  • AKA Tim
Re: Add Listview control at runtime
« Reply #1 on: February 13, 2008, 04:55:05 PM »
Maybe a control array would help. Been a while since I played with those.

Another option is to put in the most you'd need, and make them visible/invisible as you need.

Fatty

  • Guest
Re: Add Listview control at runtime
« Reply #2 on: February 13, 2008, 05:14:52 PM »
I've got a DVB that I'm working on that I would like to use the Listview control.  The problem is this: the number of listview controls depends on the number of particular objects in the drawing.  I've tried Controls.Add("Forms.Listview.1") but that only gave me an 'Invalid class string' error message.

Any takers?   :-)

Hi Matt
What I have a found in the registry (in the ROOT branch)

Code: [Select]
Private Sub Command1_Click()
Dim lvw As ListView
Dim ctl As Control
[b]Set ctl = Controls.Add("MSComctlLib.ListViewCtrl.2", "ListView1")[/b]
With ctl
.Left = 10
.Top = 40
.Height = 120
.Width = 200
.Visible = True
End With
Set lvw = ctl
With lvw
.ColumnHeaders.Add 1, "@", "Header1", 100
.ColumnHeaders.Add 2, "#", "Header2", 100
.GridLines = True
.View = lvwReport
End With
'ETC'
End Sub

Oleg

Guest

  • Guest
Re: Add Listview control at runtime
« Reply #3 on: February 14, 2008, 09:02:37 AM »
Hi Matt
What I have a found in the registry (in the ROOT branch)

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

That was it!!

Thanks again for your help.  I really appreciate it.

Fatty

  • Guest
Re: Add Listview control at runtime
« Reply #4 on: February 14, 2008, 10:20:16 AM »
Glad to help
Happy computing :)