TheSwamp

Code Red => VB(A) => Topic started by: Guest on February 13, 2008, 04:07:01 PM

Title: Add Listview control at runtime
Post by: Guest 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?   :-)
Title: Re: Add Listview control at runtime
Post by: Atook 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.
Title: Re: Add Listview control at runtime
Post by: Fatty 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
Title: Re: Add Listview control at runtime
Post by: Guest 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.
Title: Re: Add Listview control at runtime
Post by: Fatty on February 14, 2008, 10:20:16 AM
Glad to help
Happy computing :)