Displaying listview row in another form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Displaying listview row in another form

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Displaying listview row in another form

    [Originally posted by Walter Cantrell]

    Well I'm back with another newbie question on listviews.˙ I want to display a row in a listview in another form, but I can't find a reference on how to do it.˙ I have written some code but it only displays the first row in the listview no matter which row I click on.˙ Below is the code I have so far.

    Private Sub lvwCustomers_DblClick()

    ˙ ˙ Load frmCustomer
    ˙ ˙ ˙ ˙ Dim pitmCurrent As ListItem
    ˙ ˙ Dim prstCurrent As New ADODB.Recordset
    ˙ ˙ mcmdCurrent.CommandType = adCmdText
    ˙ ˙ mcmdCurrent.CommandText = "SELECT * FROM customer"
    ˙ ˙ Set prstCurrent = mcmdCurrent.Execute
    ˙ ˙
    ˙ ˙ frmCustomer.txtCompany = prstCurrent("Company")
    ˙ ˙ frmCustomer.Show vbModal
    End Sub

    Any help is appreciated.

    thanks,
    Walter Cantrell

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Displaying listview row in another form

    [Originally posted by Ravi]

    I don't understand ur prb. do u want to display clicked record to be displayed in another form's text box? if so, then u have to get selected item from list view. do u know how to get it? if not, let me know.
    bye
    ravi.

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Displaying listview row in another form

    [Originally posted by Walter Cantrell]

    Well with a little trial and error I answered my own question..well most of it.˙ I still have one slight adjustment to make and any help is appreciated.

    The code to display the selected row from a listview on the controls of another form is as follows:

    With frmCustomer
    ˙ ˙ .txtContactPerson = lvwCustomers.ListItems.Item(2)
    ˙ ˙ .txtCompany = lvwCustomers.SelectedItem.SubItems(1)
    ˙ ˙ .txtTitle = lvwCustomers.SelectedItem.SubItems(2)
    .show vbmodal
    End With

    There are more listsubitems but you get the idea.
    The problem is with the first˙ statement:

    .txtContactPerson = lvwCustomers.ListItems.Item(2)
    The index of 2 is simply the 2nd record in the database and I'm trying to figure out how to make the index match the currently selected row.

    thanks for any help,
    Walter˙ ˙

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center