borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (how to merge two or more datasets ?)Next Topic (Avi file) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : regarding listviews
Poster Message
akularaju
Level: Guest


icon regarding listviews

hi,

How to capture and send the record selected in a listview to the next form?

regards.

30-01-2004 at 03:27 PM
| Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: regarding listviews

Look at this code as an example:

Dim str As String
If lvwExample.SelectedItems.Count = 0 Then
    MessageBox.Show("Go away")
Else
    For Each lvwItem As ListViewItem In lvwExample.SelectedItems
        For i As Integer = 0 To lvwItem.SubItems.Count - 1
             str &= lvwItem.SubItems(i).Text & " "
        Next
        str &= ControlChars.CrLf
    Next
End If
MessageBox.Show(str)


I am looping through all the selected items building a string that is displayed at the end of the routine.

Depending on what you want to do, you can make the target form have a constructor that accepts a string and pass it a string that represents the selected item.

An alternative is also passing the entire selected item. the constructor would be designed to accept a ListViewItem like this:

Public Sub New(Byval lItem As ListViewItem)
   'code here
   '.....
End Sub


Hope that helps. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

30-01-2004 at 10:27 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB.Net : regarding listviews
Previous Topic (how to merge two or more datasets ?)Next Topic (Avi file) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder