Re: How to detect which ListView item user clicks?
- From: "Daniel Moth" <dmoth74@xxxxxxxxxxx>
- Date: Fri, 15 Apr 2005 18:43:26 +0100
Darren you are on!
He clicked on a listviewitem and as a result the SelectedIndexChanged event fires twice. Once with SelectedIndices.Count=0 and once with an actual item selected. Since he is not checking for that, he got the argumentexception on the line I suggested.
Robert, don't change a line in your code, stick a breakpoint on the following line and then step into once and watch the exception come up. Then point Darren to the bar :-)
index = lsvList.SelectedIndices(0)
Cheers Daniel -- http://www.danielmoth.com/Blog/
"Darren Shaffer" <darrenshaffer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:%23dX5OGeQFHA.3404@xxxxxxxxxxxxxxxxxxxxxxx
Daniel - the bet is two pints at MEDC ;-)
I've gotta believe he at least clicked an item in the ListView before he got the exception while testing, which means there is at least one selected index and he's 'off-by-one' on his subitems index.
Robert - tt is always a good idea to do this:
if ( lvwTasks.SelectedIndices.Count > 0 ) { ListViewItem lvi = lvwTasks.Items[lvwTasks.SelectedIndices[0]]; // }
before inspecting the SelectedIndices collection.
Ok Robert - there's a lot riding on your code man - what was your issue? -- Darren Shaffer .NET Compact Framework MVP Principal Architect Connected Innovation www.connectedinnovation.com
"Daniel Moth" <dmoth74@xxxxxxxxxxx> wrote in message news:eSIwIQcQFHA.3496@xxxxxxxxxxxxxxxxxxxxxxx>I bet the arg out of range exception is right here: How much? :-D
I bet it is here: index = lsvList.SelectedIndices(0)
Cheers Daniel -- http://www.danielmoth.com/Blog/
"Darren Shaffer" <darrenshaffer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:u9fWdJcQFHA.2132@xxxxxxxxxxxxxxxxxxxxxxxI bet the arg out of range exception is right here: updQt.Value = lsvList.Items(index).SubItems(1).Text
There is probably no SubItems(1) and you should be using SubItems(0).Text
-- Darren Shaffer .NET Compact Framework MVP Principal Architect Connected Innovation www.connectedinnovation.com
"Robert" <rxl@xxxxxxxxxxx> wrote in message news:OfW8zXYQFHA.3156@xxxxxxxxxxxxxxxxxxxxxxx
Could you be more specific?
I tried follwing code and it got an exception saying something like System.argumentsOutRange
Private Sub lsvList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lsvList.SelectedIndexChanged
Dim index As Integer
index = lsvList.SelectedIndices(0)
txtFMPNumber.Text = lsvList.Items(index).Text
updQt.Value = lsvList.Items(index).SubItems(1).Text
End Sub
Any ideas?
"Darren Shaffer" <darrenshaffer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:eZe7yFVQFHA.248@xxxxxxxxxxxxxxxxxxxxxxxyou iterate the items and inspect their Checked state if using checkboxes
or inspect the SelectedIndices array if not.
--
Darren Shaffer
.NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
"Robert" <rxl@xxxxxxxxxxx> wrote in message news:uJVSU0TQFHA.3868@xxxxxxxxxxxxxxxxxxxxxxxI can add items to the ListView but could find a way to know which row (in detail view) that the user taps.
The .NETCF does not pass current clicked index in the event procedures any more. So how do you know which row user taps?
Thanks in advance!
.
- Follow-Ups:
- Re: How to detect which ListView item user clicks?
- From: Darren Shaffer
- Re: How to detect which ListView item user clicks?
- References:
- How to detect which ListView item user clicks?
- From: Robert
- Re: How to detect which ListView item user clicks?
- From: Darren Shaffer
- Re: How to detect which ListView item user clicks?
- From: Robert
- Re: How to detect which ListView item user clicks?
- From: Darren Shaffer
- Re: How to detect which ListView item user clicks?
- From: Daniel Moth
- Re: How to detect which ListView item user clicks?
- From: Darren Shaffer
- How to detect which ListView item user clicks?
- Prev by Date: Re: How to detect which ListView item user clicks?
- Next by Date: Re: How to detect which ListView item user clicks?
- Previous by thread: Re: How to detect which ListView item user clicks?
- Next by thread: Re: How to detect which ListView item user clicks?
- Index(es):
Relevant Pages
|