Determining Item / Subitem Clicked in a ListView

Monday Oct 13th 2003 by Chris Eastwood
Share:

This code shows how to determine just what was clicked in a listview - ie. icon, text, subitem, status icon etc. VB6 (may work with VB6) (Originally posted January 25, 2000.)

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

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved