0

HI all

i am working on a project where i am adding login and password. Also i add button if someone forget his\her password so they can able to retrive it. for this i put 2 textboxes one is email and other is username which will retrive data from listview. now i know how to search item with below code

ListView1.Focus()
        For i = 0 To ListView1.Items.Count - 1
            If ListView1.Items(i).SubItems(0).Text = TextBox1.Text Then
                ListView1.Items(i).Selected = True
                MsgBox(" Found'")

            End If
        Next

but i want that when item found the message box must appear showing column1(username) and column2(password)

how to do that

2
Contributors
1
Reply
11
Views
2 Years
Discussion Span
Last Post by djjeavons
0

Hi

If the user name is in column 1 and that is what you are using to match against your text box then you already have the code via the SubItems property and can use this in your message box.

MessageBox.Show(String.Format("Username: {0}, Password: {1}", ListView1.Items(i).SubItems(0).Text, ListView1.Items(i).SubItems(1).Text))

You will also need to add an Exit For once you have found your match otherwise you will be looping unnecessarily once a match is found.

HTH

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.