Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the SelectedItem or SelectedIndex of ListView in vb.net?

As you know by question that what I want. I was using listbox. In ListBox we can get selected item by a simple line of code: listbox1.SelectedItem. Now I am using ListView, how I get the SelectedItem or SelectedIndex of ListView.

like image 559
Shahrukh Avatar asked Jan 01 '12 15:01

Shahrukh


People also ask

Is used to obtain all selected items in the ListView control?

You can access all items that are selected in a ListView control by using the ListView. SelectedItems property.

How do I add items to a ListView in VBA?

You can use ListView1. Items. Insert(index, ListViewItem) to add the new item to the specific position.

What is ListView in VB net?

The ListView control is used to display a list of items. Along with the TreeView control, it allows you to create a Windows Explorer like interface. Let's click on a ListView control from the Toolbox and place it on the form. The ListView control displays a list of items along with icons.


2 Answers

VB6: Listview1.selecteditem

VB10: Listview1.FocusedItem.Text

like image 99
Raphael Estrada Avatar answered Sep 16 '22 12:09

Raphael Estrada


Here's the answer that I found for my question:

urlList1.FocusedItem.Index

And I am getting selected item value by:

urlList1.Items(urlList1.FocusedItem.Index).SubItems(0).Text
like image 29
Shahrukh Avatar answered Sep 18 '22 12:09

Shahrukh