Morning all,
I have set up a user form with a dynamic listview. The code is as follows:
When the user form loads it highlights the following:
with the error:
Compile Error: User-defined type not defined
If I drag a listview on to the form and then delete it the above code works fine.
What am I missing to allow me to create a dynamic listview without having to add the control first via the toolbox
Thanks
I have set up a user form with a dynamic listview. The code is as follows:
Code:
Option Explicit
Public WithEvents lvwDocList As MSComctlLib.ListView
Private Sub UserForm_Initialize()
Set lvwDocList = Me.Controls.Add("MSComctlLib.ListViewCtrl.2", "ListView1")
With lvwDocList
.Appearance = ccFlat
.BorderStyle = ccNone
.Left = 0
.Top = 0
.Height = 100
.Width = 100
.HideColumnHeaders = True
.View = lvwReport
.Gridlines = True
.FullRowSelect = True
.CheckBoxes = False
.HideSelection = False
.LabelEdit = lvwManual
.ColumnHeaders.Add , , "Column1", 25, lvwColumnLeft
.ColumnHeaders.Add , , "Column2", 25, lvwColumnLeft
.ColumnHeaders.Add , , "Column3", 25, lvwColumnLeft
.ColumnHeaders.Add , , "Column4", 25, lvwColumnLeft
End With
End Sub
When the user form loads it highlights the following:
Code:
Public WithEvents lvwDocList As MSComctlLib.ListView
with the error:
Compile Error: User-defined type not defined
If I drag a listview on to the form and then delete it the above code works fine.
What am I missing to allow me to create a dynamic listview without having to add the control first via the toolbox
Thanks