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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,990
Messages
5,856,679
Members
431,828
Latest member
kARTIK12345

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