Solved

Currently Selected item in ListView

Posted on 2009-04-07
6
320 Views
Last Modified: 2012-05-06
How could i get the index of   currently selected item in a listview if mulple selection is allowed.
0
Comment
Question by:replyanshu
  • 2
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
Usually there is a collection of "selected indices".

For example, in VB.Net:

        For i As Integer = 0 To ListView1.SelectedIndices.Count - 1
            Dim index As Integer = ListView1.SelectedIndices(i)
            Dim lvi As ListViewItem = ListView1.Items(index)
        Next

You could also access the items directly:

        For Each lvi As ListView In ListView1.SelectedItems
            ' ...do something with "lvi"...
        Next
0
 

Author Comment

by:replyanshu
Comment Utility
I got Solution for my self I had develop a function which return the currently selected index:

 Private Function FindIndex() As Integer
        Dim intSelIndex As Integer
              If Me.lv_LineItem.lvDisplay.SelectedItems.Count = 1 Then
            m_ValueofZerothIndex = Me.lv_LineItem.lvDisplay.SelectedIndices.Item(0)
            intSelIndex = 0
        Else
            If m_ValueofZerothIndex = Me.lv_LineItem.lvDisplay.SelectedIndices.Item(0) Then
                m_ValueofZerothIndex = Me.lv_LineItem.lvDisplay.SelectedIndices.Item(0)
                intSelIndex = Me.lv_LineItem.lvDisplay.SelectedItems.Count - 1
            Else
                m_ValueofZerothIndex = Me.lv_LineItem.lvDisplay.SelectedIndices.Item(0)
                intSelIndex = 0
            End If
        End If
        Return intSelIndex
    End Function
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
...I showed you how to use the SelectedIndices() property over seven days ago!...   =\
0
 

Author Comment

by:replyanshu
Comment Utility
Yes but i  get this even before than this from google.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now