PDA

View Full Version : ListView at runtime



garydp
04-22-2014, 08:26 AM
Hi,

I have created a form and at runtime it creates a listview using the following

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

is there a way of adding a double click event to the listview?

before i used to add the listview at design time and when the program was run and the listview was populated i could double click on one of the lines and open up a different form. I havent been able to work out how to do this when its created at runtime.

Bob Phillips
04-22-2014, 08:34 AM
Isn't DblClick one of its events. If you select the control and go to view code you should see it as an option in the dropdown.

garydp
04-22-2014, 08:37 AM
yes it is when created at design time but this doesnt seem to work when created at runtime

garydp
04-22-2014, 10:51 AM
its ok i have found out how to do it. When i declared lstequip i did it as a listview. i change it from this to

Public WithEvents lstequip As ListView

now i can use

Private Sub lstequip_dblclick()

End Sub