CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    199

    Listview - what row was clicked??

    This is driving me nuts - simple matter in VC++ to get the index (row) of a listview when clicked.

    All I want to do is get the integer index of the row clicked- that's it. I can't find it anywhere... read all the MSDN BS and could not find it.

    Help!

  2. #2
    Join Date
    Jul 2003
    Location
    Bali, Indonesia
    Posts
    103

    Re: Listview - what row was clicked??

    Listview is not a row based control, it is item base control so I think it is not necessary to get a row in a Listview. And I found Listview is very helpful to find the selected item inside it by using the "listview.SelectedItems" method.

    If u want the control that row base why don't you use the Listbox control ?

  3. #3
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: Listview - what row was clicked??

    I'm sick of people bagging MSDN. BS indeed? Some times I think people read it with their eyes closed. A quick look at the ListView documentation reveals a GetItemAt method, described thusly:
    Retrieves the item at the specified location.
    How would you get the coordinates? The MouseClick event provides them for you, or you could use the MouseDown event as in the code example provided in the GetItemAt documentation. There's also the HitTest method, described thusly:
    Provides item information, given an x- and y-coordinate.
    Easy to do; easy to find.
    Last edited by jmcilhinney; December 10th, 2007 at 09:50 PM.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

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