"n. Smith" <ni***@yahoo.dk > schrieb:
Is it normal that the ListView fires the selectedinexcha nge event
twice?
I have a LvLoaners list view item that updates 3 text boxes (code
below), when I click on an item. I have set MultiSelect to False.
The first click goes as planned, but all subsqequent clicks seem to
fire the event twice. The first firing triggers an ArgumentExcepti on,
resulting in nItem not being initialised. That's why I have the first
Catch Block.
That's not a bug. It's a feature.
When the user initiates a selection change that effectively results in all
selected items being deselected and then one or more items being
(re)selected, the control will raise the event twice, first for deselecting
the items and then for selecting them again (although the user will only see
that as a single operation). You can avoid the exception by extending your
code like this:
\\\
Dim SourceControl As ListView = DirectCast(send er, ListView)
If SourceControl.S electedItems.Le ngth > 0 Then
...
End If
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>