Show ListView Data in TextBox or Get Listview Selected Items in VB6.0

If you want to get or Show Listview Items in TextBox or other Cointrols like: Lebel, Listbox etc., So, you will find the steps described through SKOTechLearn. In this post, we learn about show ListView data in TextBox or Show Listview Selected Items in Other control in Visual Basic6.0.

From where to Add Listview contol in Toolbox?

So, for showing selected items from Listview to TextBox, we have to follow the some following steps.

When you process on this control then you always think some questions Like:
How to display items to TextBox in VB?
How to get items from this control to TextBox?

SKOTechLearn will solve all related questions described above.

Step 1: Add Data or Items to ListView

If you want to show items in TextBox, you have to remember that this control cannot empty or without items. At least one record associated with this control as shown in bellow image. Check here to Add Data or Items.
ListView Data for show in textbox
Item's View

Suppose, we define 4 columns with Column Header: EMP_Name, EMP_Age, EMP_Address, EMP_MoNo And there is 4 records related with these column.

Suppose, we have 4 TextBox with textname: 'EMPName_Txt', 'EMPAge_Txt', 'EMPAddress_Txt', 'EMPMono_Txt'. And selected item must be display in given related box. I also drag some Label to define the this box related Name to easily understand which text present the column value.

Here, we will change Listview1 Name as Lstvdata1.

Tips to edit or delete selected Listview Items

Step 2: Show Listview Selected Items In TextBox

For display record in TextBox follow the steps as describe bellow.

 1.  Double click on Lstvdata1

 2.  Select "ItemClick" events from event selection box like bellow.

Code Window (ItemClick Event)
Private Sub Lstvdata1_ItemClick(ByVal Item As MSComctlLib.ListItem)

End Sub
ListView code event for show data in Textbox
Code Window with Lstvdata1 Event

There is another way to reach event window, just right click on control and select "View Code" option from drop down menu. But if you want to reach that particular control's code event, just double click on that control. After that type code in "Lstvdata1_ItemClick(ByVal Item As MSComctlLib.ListItem)" events.

Learn tips to Show Listview checked item in vb6.0

Follow Sample Code:
Private Sub Lstvdata1_ItemClick(ByVal Item As MSComctlLib.ListItem)
 'SelectedItem.Text show First Column Data
 EMPName_Txt.Text = Lstvdata1.SelectedItem.Text
 'SelectedItem.SubItems(1) show Second Column Data
 EMPAge_Txt.Text = Lstvdata1.SelectedItem.SubItems(1)
 'SelectedItem.SubItems(2) show Third Column Data
 EMPAddress_Txt.Text = Lstvdata1.SelectedItem.SubItems(2)
 'SelectedItem.SubItems(3) show Forth Column Data
 EMPMoNo_Txt.Text = Lstvdata1.SelectedItem.SubItems(3)

End Sub


Private Sub Lstvdata1_ItemClick(ByVal Item As MSComctlLib.ListItem)

 EMPName_Txt.Text = Item.SelectedItem.Text
 EMPAge_Txt.Text = Item.SelectedItem.SubItems(1)
 EMPAddress_Txt.Text = Item.SelectedItem.SubItems(2)
 EMPMoNo_Txt.Text = Item.SelectedItem.SubItems(3)

 End Sub

As you can see that the selected data will be get from column wise:
SelectedItem.Text :  show First Column Data
SelectedItem.SubItems(1) :  show Second Column Data
SelectedItem.SubItems(2) :  show Third Column Data
SelectedItem.SubItems(3) :  show Forth Column Data

Step 3: Run Application to View output

After apply above code, run project. After that click or select any one of row data , as well as you select row data, it will show in its related Box.

Selection of record can be proceed by pressing Arrow Up and Arrow Down key.
ListView Item Selection for show data in Textbox
Lstvdata1 Item Selection
This will present if we click or select any row items from this control. It shows record in its related Box.

This is the simple process described in above image presenting to easily understand. This has some feature to design or change look according to your desire. This control is only way to fast item's presentation. It can take less time to show items compare than any other Table's control.

This is the step by step instruction to Show ListView data in TextBox in Visual Basic6.0 easy Tips with SKOTechLearn.

Add column header with items in MSHFlexgrid Tips