Results 1 to 5 of 5

Thread: [RESOLVED] How to get current item in listview

  1. #1

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Resolved [RESOLVED] How to get current item in listview

    In fact i can loop through items of listview and determine items(i) is selected state or not. But i want to ask you is there method similar listview1.currentitem.text for instance.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  2. #2

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: How to get current item in listview

    i can use :
    Code:
    Private Sub ListView1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
            MsgBox(ListView1.GetItemAt(e.X, e.Y).Text)
        End Sub
    any other ideas ?
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: How to get current item in listview

    Use ListView.FocusedItem property
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: How to get current item in listview

    Thanks
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  5. #5
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] How to get current item in listview

    It depends what you mean by current item? My memory of VB6 is hazy now but if I recall correctly this will return the currently selected item?

    If that is what you need then FocusedItem is not a reliable method as it is possible that the focused item is not selected (see the MSDN entry for focuseditem for details)

    Assuming there is a selected item then MyListView.SelectedItems(0) will return the selecteditem (assuming there is one) in a single selection listview. For a multi-select listview then things are a bit different and again it depends to some extent what you mean by "current item".
    Last edited by keystone_paul; Dec 30th, 2009 at 03:49 PM.

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