Fill textbox from Listview

teodormircea

Active Member
Joined
Jan 8, 2008
Messages
331
Hello forum<


What is the most easy way to fill textbox from an listview,
I have a listview with 5 columns , and i want to fill 5 textbox when i click on a line from listview
thanks for advice;)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Colin Legg

MrExcel MVP
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi,

I added a listview control and five textboxes to my userform. I left them with their default names, so Textbox1, Textbox2,.... Textbox5.

[I populated the listview in the userform's initialise event handler.]

I then added this event handler code to the userform's class module which should give you the general idea:
Code:
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    
    Dim c As Integer
    
    With Item
        TextBox1.Text = .Text
        
        For c = 2 To 5
            Controls("TextBox" & c).Text = .SubItems(c - 1)
        Next c
    End With
    
End Sub
 

Forum statistics

Threads
1,171,227
Messages
5,874,480
Members
433,054
Latest member
Agridoc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top