473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can i get the index of a listview

Jan
Hello everybody.

Can someone tell me how i can get the index of an listview.
I tried it at th e following way:

public intIndexListview As ListView.SelectedIndexCollection

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

intIndexListview = ListView1.SelectedIndices.Index ( i get an error on this
line)
TextBox2.Text = intIndexListview

end sub

newbee question i know

thanks for your help ia
Nov 21 '05 #1
4 5905
"Jan" <ca*****@planet.nl> schrieb:
Can someone tell me how i can get the index of an listview.
I tried it at th e following way:

public intIndexListview As ListView.SelectedIndexCollection

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

intIndexListview = ListView1.SelectedIndices.Index ( i get an error on
this
line)


In your 'SelectedIndexChanged' event handler:

\\\
Dim SourceControl As ListView = DirectCast(sender, ListView)
If SourceControl.SelectedIndices.Length > 0 Then
Dim IndexListView As Integer = SourceControl.SelectedIndices.Length
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
"Jan" <ca*****@planet.nl> schrieb:
Can someone tell me how i can get the index of an listview.
I tried it at th e following way:

public intIndexListview As ListView.SelectedIndexCollection

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

intIndexListview = ListView1.SelectedIndices.Index ( i get an error on
this
line)


In your 'SelectedIndexChanged' event handler:

\\\
Dim SourceControl As ListView = DirectCast(sender, ListView)
If SourceControl.SelectedIndices.Length > 0 Then
Dim IndexListView As Integer = SourceControl.SelectedIndices.Length
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Jan,

Have a look at this page

http://msdn.microsoft.com/library/de...dicestopic.asp

I hope this helps?

Cor
Nov 21 '05 #4
Jan,

Have a look at this page

http://msdn.microsoft.com/library/de...dicestopic.asp

I hope this helps?

Cor
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Samuel R. Neff | last post by:
I'm having a index problem with ListView SubItems. If I add multiple columns to the listview and then add items with associated subitems, the ListView displays fine. Then if I delete a column via...
0
by: Graham | last post by:
Hi everyone I have a form which contains a ListView control. The code handles the SelectedIndexChanged event, and changes some icons on some items in the ListView. I've found that when I...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
10
by: Adam Honek | last post by:
This is probably a silly question but oh well, I can't find the answer looking via code. Having an imagelist already, how does one set an icon for a list view's sub items? I'm using the code...
1
by: plmanikandan | last post by:
Hi, I have a listview with items,subitems.I tems and subitems are added as below listView1.View = View.Details; listView1.Columns.Add("Column 1", 100,HorizontalAlignment.Center);...
2
by: forest demon | last post by:
in a different app, i can grab the index of a ListBox, but when i try it with a listview with only one column, i'm having issues. the first line (string) below works as expected. the second line...
4
by: forest demon | last post by:
I have an IList/Collection that contains items in a ListView. If i click on an item in the ListView, i can capture the index (lv.SelectedItems.Index) and reference the correct item in the...
2
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I'm trying to get the index of a selected Item in ListView. I'm using the SelectedItemChange Event, but i can't get the item index (like in listbox for i.e). How can i get the index? ...
3
by: sstein | last post by:
Hi, I am having a bit of trouble with some C# code. I can get it working in VB.NET, but can't seem to work out how to get the same code working in C#. I have a listview which stores information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.