CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 1999
    Posts
    6

    TreeView and WithEvents

    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



  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: TreeView and WithEvents

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



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

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: TreeView and WithEvents

    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.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: TreeView and WithEvents

    Yes, the first thing you need to check is the component. Then try this:

    Private WithEvent LV as MSComctlLib.ListView



    Regards,

    Michi
    MCSE, MCDBA

  5. #5
    Join Date
    Nov 1999
    Posts
    6

    Re: TreeView and WithEvents

    Thank´s! Now it work´s.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured