You can use code i.e. "WithEvents" to build a control at runtime. However, this only works for controls that are integrated in to the IDE. How would i generate a Listview the same way programatically.
Regards,
Jenova
Printable View
You can use code i.e. "WithEvents" to build a control at runtime. However, this only works for controls that are integrated in to the IDE. How would i generate a Listview the same way programatically.
Regards,
Jenova
You can add it dynamically just like a CommandButton. The hard part is knowing the correct ProgID. A little Googling and voila:
VB Code:
Private WithEvents MyListView As ListView Private Sub Form_Load() Set MyListView = Controls.Add("MSComctlLib.ListViewCtrl.2", "MyListView", Me) MyListView.Visible = True End Sub Private Sub MyListView_GotFocus() Debug.Print "I'm here!" End Sub Private Sub MyListView_LostFocus() Debug.Print "I'm gone!" End Sub
Of course, you'll need to reference the MsComCtl.ocx in your project.
To get it to work, you would have to uncheck the "Remove information about unused activeX controls" in the project properties.
You don't have to do that if you actually use something from that OCX by adding it from the toolbox. If you do it all dynamically, VB will remove the reference to that OCX because it doesn't know you are using it anywhere...
I tried something similar to that but it does not work. if you reference the control then you get an error saying that it can not be referenced and to un-reference it. If you don't refrence it you just get an error saying that the user defined type has not been defined.
Regards,
Jenova
you need to add a reference to "Microsoft Windows Common Controls 6.0"
If by add a reference you mean tick the Microsoft Common Controls 6.0 in the components dialog, i did and it told me to unreference it. How do i uncheck the "Remove information about unused activeX controls" i cant find it in the project properties
Regards,
Jenova
It's under the "Make" tab in the project properties. It's a check box near the bottom.
Also for Microsoft Windows Common Controls 5.0 (comctl32.ocx <- Supports XPstyle)
http://www.vbforums.com/showpost.php...14&postcount=4
I have been using the Working Model Edition so i think that is why it did not work. I will try the professional edition when i get home from college. Cheers guys. :D
Regards,
Carl