Results 1 to 3 of 3

Thread: Selected item, Listview and multiple selections.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Question

    Hi I have a listview that has data loaded onto itself. If a user selects a few items and clicks the ok button I want it to add each selected item into a database. I have this code:

    Dim i, j As Integer
    Dim strSendTo As String
    Dim ShellX As String

    strSendTo = ""
    LsvEmail.SelectedItem.Text Then
    For i = 1 To LsvEmail.ListItems.Count - 1
    If LsvEmail.SelectedItem.Text = LsvEmail.ListItems(i).Text Then
    strSendTo = strSendTo + LsvEmail.ListItems(i).Text + ";"
    End If
    Next
    If strSendTo = "" Then
    MsgBox "Please reselect your Emailing Client as you have not yet selected one."
    Exit Sub
    End If

    strSendTo = Left(strSendTo, Len(strSendTo) - 1)

    ShellX = "start mailto:" + strSendTo
    Shell ShellX


    Now this works to a point. The line :
    If LsvEmail.SelectedItem.Text = LsvEmail.ListItems(i).Text Then
    is a problem because it just sits at the first selecteditem. How can I move on to the next selecteditem in a listview?

    Any help would be appreciated and thanx in advance.

    Mike

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I think your code is over complicated.

    You can loop through the items like this:
    Code:
    For i = 1 To LsvEmail.ListItems.Count
      If LsvEmail.ListItems(i).Selected Then
        strSendTo = strSendTo + LsvEmail.ListItems(i).Text + ";"
      End If
    Next
    Mark
    -------------------

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Thumbs up

    Thanks. At first I didn;t think it was gonna work but I forgot to take the -1 off of the for statement. Thanks once again.

    Mike

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