Click to See Complete Forum and Search --> : TreeView and WithEvents


hannes c
July 16th, 2001, 09:52 AM
Hello *,


I have an usercontrol with the following
lines of code:


private withevents LV as ListView
private withevents TV as TreeView




When I try to compile these lines I get the following error message, for the line with TreeView:
A module it not a valid type

Without that line the code can be compiled without an error message.

Any idea why I can´t declare a treeview control
with WithEvents inside an usercontrol

Thank´s
hannes

Cimperiali
July 16th, 2001, 10:20 AM
Check if you have added the component to your usercontrol (right click on toolbar, add microsoft windows common controls 6.0)

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

Clearcode
July 16th, 2001, 10:35 AM
In Visual Basic 5 and 6, a code module cannot be an event sink so therefore you cannot dim anything WithEvents in a .bas module.

Try adding a global class module (.cls) and put the declaration in there. You can instantiate that class from the main .bas if you wish.

HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.

michi
July 16th, 2001, 11:00 AM
Yes, the first thing you need to check is the component. Then try this:

Private WithEvent LV as MSComctlLib.ListView



Regards,

Michi
MCSE, MCDBA

hannes c
July 17th, 2001, 02:25 AM
Thank´s! Now it work´s.