473,395 Members | 1,443 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,395 software developers and data experts.

I and the listview again

Hi all....

I've a listview whit 6 items and 3 columns just for a exemple, and I've
tryed to do this...

;;;;;
Private Sub listview1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles listview1.SelectedIndexChanged
MsgBox(listview1.SelectedItems.Item(0).Index.ToStr ing)
End Sub
;;;;;;;;;;

when the event is triggered for the first time it works just fine, but on
the second time:

;;;;;;
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred
in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values.
;;;;;;;;

if i put this code for a click event of the listview it always works
--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br
Nov 20 '05 #1
2 1371
Daniel,

I'm not sure of the inner workings, but it appears that the
SelectedIndexChanged event is fired first as you move off an item and then
again as you move onto another item. If its a single select listview, or
only one item is selected, as you move off the item, SelectedItem(0) will be
Nothing, and so an exception is thrown. You can enclose it in a Try/Catch
block

Try
MsgBox(listview1.SelectedItems.Item(0).Index.ToStr ing)
Catch e as ArgumentOutOfRangeException
'Do nothing
End Try

Stephen

"Daniel Sélen Secches" <danielATcwdDOTcomDOTbr> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl...
Hi all....

I've a listview whit 6 items and 3 columns just for a exemple, and I've
tryed to do this...

;;;;;
Private Sub listview1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listview1.SelectedIndexChanged
MsgBox(listview1.SelectedItems.Item(0).Index.ToStr ing)
End Sub
;;;;;;;;;;

when the event is triggered for the first time it works just fine, but on
the second time:

;;;;;;
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values.
;;;;;;;;

if i put this code for a click event of the listview it always works
--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br

Nov 20 '05 #2
tks... it's works fine...
"Stephen Muecke" <st*****@senet.com.au> escreveu na mensagem
news:uj*************@tk2msftngp13.phx.gbl...
Daniel,

I'm not sure of the inner workings, but it appears that the
SelectedIndexChanged event is fired first as you move off an item and then
again as you move onto another item. If its a single select listview, or
only one item is selected, as you move off the item, SelectedItem(0) will be Nothing, and so an exception is thrown. You can enclose it in a Try/Catch
block

Try
MsgBox(listview1.SelectedItems.Item(0).Index.ToStr ing)
Catch e as ArgumentOutOfRangeException
'Do nothing
End Try

Stephen

"Daniel Sélen Secches" <danielATcwdDOTcomDOTbr> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl...
Hi all....

I've a listview whit 6 items and 3 columns just for a exemple, and I've
tryed to do this...

;;;;;
Private Sub listview1_SelectedIndexChanged(ByVal sender As Object,

ByVal
e As System.EventArgs) Handles listview1.SelectedIndexChanged
MsgBox(listview1.SelectedItems.Item(0).Index.ToStr ing)
End Sub
;;;;;;;;;;

when the event is triggered for the first time it works just fine, but on the second time:

;;;;;;
An unhandled exception of type 'System.ArgumentOutOfRangeException'

occurred
in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values.
;;;;;;;;

if i put this code for a click event of the listview it always works
--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br


Nov 20 '05 #3

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

Similar topics

2
by: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from...
6
by: Nick | last post by:
Hi there, I'm trying to implement drag-drop for my listview control in large icon view mode. Unfortunately the order of the items gets completely messed up upon inserting the item back into the...
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
6
by: Josef Brunner | last post by:
Hi, I have a problem using two ListView controls on one and the same form: Problem: The second ListView is never focused. No matter where I "click" non of the items within the ListView is...
5
by: XiScO | last post by:
Hi! sometime ago, a friend show me that in BC++ you could add an objet to each element of a listview. Now I wnat to know if it is possible to do this on VB.net 2005. I've a collection of objects...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.