Determining Item / Subitem Clicked in a ListView

This small code sample shows how to detect where the mouse was clicked in a listview.

Microsoft, in all their wisdom didn't give us VB developers an easy way to determine where in the listview the mouse was clicked. If you want to place a combo/textbox over a listitem / subitem, it can prove tricky to find out what item was clicked - this code will show you just how to do that.

The code uses the LVHITTESTINFO structure ported from the commctl.h C header file and the LVHT_ constants. The structure will let you know where in the listview the mouse was clicked, including :

  • An Items Icon (including SubItem Icons)
  • On Text
  • On a State Icon
  • Nowhere !

Download zipped project file

Screen-shot



Comments

  • Damn right it is

    Posted by Capoustaits on 02/09/2013 04:12pm

    Belly Belts Much like the Ab Tek Can't Provide you with Six-pack Abdominal muscles reduce abdominal training methods Choosing the best Abdominal training exercises to your Workout Best Belly Training regarding Joggers [url=http://the-flex-belt.org]Ab Flex Belt[/url] Belly Slide with regard to About three Instant Ab Exercise routine Associate Exercise - Abdominal Exercises The amount regarding anterior pelvic tilt and stomach muscle mass strength The awesome Stomach Workout That Performs!

    Reply
  • Implementation in Delphi

    Posted by gcsaba2 on 10/27/2006 08:51am

    http://www.enyem.com/wiki/index.php/TListView_subitem_click_detection

    Reply
  • subclick is nice, where is the code

    Posted by wiroon on 07/11/2005 10:56pm

    I am new at codeguru. I have logged-in and still can not see the code. Tell me how to view the code.

    Reply
  • vb code comments

    Posted by Legacy on 08/20/2003 12:00am

    Originally posted by: shakir

    nice code tell u after checking it
    by

    Reply
  • 2017_subclick

    Posted by Legacy on 07/17/2003 12:00am

    Originally posted by: Chege

    Sweet stuff! Saved my skin!!!
    

    Reply
  • 2017_subclick

    Posted by Legacy on 07/15/2003 12:00am

    Originally posted by: Cary Martin

    You did a good job here. This was really useful.

    thanks

    Reply
  • Pretty cool isn't it!

    Posted by Legacy on 04/22/2003 12:00am

    Originally posted by: Wong Liang

    Coool

    Reply
  • This is great :) Tanx

    Posted by Legacy on 08/13/2002 12:00am

    Originally posted by: Sam Vazirian

    Just wanted to say TANX

    Reply
  • Thank u

    Posted by Legacy on 04/19/2002 12:00am

    Originally posted by: Murali

    thank u very much...
    i got so many things from this....

    Reply
  • Simply AWESOME!

    Posted by Legacy on 01/17/2002 12:00am

    Originally posted by: Lanny Schiele

    This is just to good to be true! Thank you!

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date