• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Show in the textbox the selected item in the listview to edit

Visor

Member
Dear forum friends, I have a form with a listview control. I would like to be able to do that when selecting a line or item, the data of this line is shown in the testbox and then I can edit it.

What is done in the button that is in the form does what I want but it is only working for one row, what I want is that it works for any row that I select in the listview

I hope you can help me, I upload a file so you can see it
thanks in advance for the support.
 

Attachments

  • Mostrar lo seleccionado en ListtView en los Textbox.xlsm
    28.3 KB · Views: 19
Code:
Private Sub CmdMostarTbx_Click()
'coloca datos en el textbox
Dim r As Long, c As Integer, col As Integer

  With ListView1
    col = .ColumnHeaders.Count - 1
    r = .SelectedItem.Index
    For c = 1 To col
      Debug.Print r, c, Controls("Tbx" & c).Value
      'Tbx1 = ListView1.ListItems(1).ListSubItems(1)
      Controls("Tbx" & c).Value = .ListItems(r).ListSubItems(c)
    Next c
    '.SetFocus
  End With
End Sub
 
Thanks for your quick response, it's really great a short code that does what I need
The loop increases the column, according to the index of the selected item
great!!

Solved theme
 
Back
Top