ListBox vs. ListView

M

Mike

Is there a way to get a ListView control to fire its
SelectedIndexChanged event like the ListBox control? When the user
selects multiple items at once, the ListView fires the event as each
item gets selected. The ListBox waits to fire the event until all
selections are complete.

Thanks,
Mike
 
J

Jeff Johnson

Is there a way to get a ListView control to fire its
SelectedIndexChanged event like the ListBox control? When the user
selects multiple items at once, the ListView fires the event as each
item gets selected. The ListBox waits to fire the event until all
selections are complete.

It does? How do it KNOW that the selections are complete?

(I, for one, welcome our new telepathic list box overlords....)
 
M

Mike

It does? How do it KNOW that the selections are complete?

(I, for one, welcome our new telepathic list box overlords....)

How could it not know? If I click on the first of 100 items and then
shift-click the last item, I think the control needs to know it is
selecting all 100 items or else how could it do it?
 
J

Jeff Johnson

How could it not know? If I click on the first of 100 items and then
shift-click the last item, I think the control needs to know it is
selecting all 100 items or else how could it do it?

Well, you didn't specify what type of multi-selection you were using.
There's also the type where you can Ctrl+click items, and do it as many
times as you want.

And you're saying that the first click (on the "anchor" item) doesn't fire
SelectedIndexChanged? I'm having difficulty believing that.
 
M

Mike

Well, you didn't specify what type of multi-selection you were using.
There's also the type where you can Ctrl+click items, and do it as many
times as you want.

And you're saying that the first click (on the "anchor" item) doesn't fire
SelectedIndexChanged? I'm having difficulty believing that.

First, I said this is when they select multiple "at once". Sorry that
wasn't clear enough for you, but the shift-click is the only way I'm
aware of to do that. With ctrl+click, you pick items one at a time,
not all at once.

Second, I never said that the first click doesn't fire the event. I am
only talking about the shift-click situation. Again, that single click
is not selecting multiple items at one time.
 
J

Jeff Johnson

Well, you didn't specify what type of multi-selection you were using.
There's also the type where you can Ctrl+click items, and do it as many
times as you want.

And you're saying that the first click (on the "anchor" item) doesn't fire
SelectedIndexChanged? I'm having difficulty believing that.

Oh, wait, you're saying you only want two event firings: the first and the
last. I think the behavior you're seeing is due to the fact that the list
view is far more complicated than the list box. For example, the list items
are not necessarily in the same order that you see them, and they're
independent objects as well, so the list view has to notify them that
they've been selected and they in turn probably raise an event which the
list box passes on. (This is speculation, of course.)

So here's the real question: would it be that hard to change your code to
deal with it? Are you updating your UI dynamically based on the selections?
 
J

Jeff Johnson

First, I said this is when they select multiple "at once". Sorry that
wasn't clear enough for you, but the shift-click is the only way I'm
aware of to do that. With ctrl+click, you pick items one at a time,
not all at once.

Welcome to the ambiguity of the English language. To you, "at once" meant in
a single action. To me, it meant "without doing anything else in the
application in-between, like clicking on a button." Saying "Shift+click," as
you did in your first reply, makes it perfectly clear, though, and now we're
on the same page, although ultimately I don't think you're going to get the
answer you want.
 
M

Mike

Oh, wait, you're saying you only want two event firings: the first and the
last. I think the behavior you're seeing is due to the fact that the list
view is far more complicated than the list box. For example, the list items
are not necessarily in the same order that you see them, and they're
independent objects as well, so the list view has to notify them that
they've been selected and they in turn probably raise an event which the
list box passes on. (This is speculation, of course.)

So here's the real question: would it be that hard to change your code to
deal with it? Are you updating your UI dynamically based on the selections?- Hide quoted text -

- Show quoted text -

Yeah, what you are saying about the cause makes sense. I could change
things to handle how it works, I was just hoping there was a simple
property or something somewhere that would make it work like the list
box. I'd rather not use the list box for other reasons I won't get
into here.
 
M

Mike

Welcome to the ambiguity of the English language. To you, "at once" meantin
a single action. To me, it meant "without doing anything else in the
application in-between, like clicking on a button." Saying "Shift+click,"as
you did in your first reply, makes it perfectly clear, though, and now we're
on the same page, although ultimately I don't think you're going to get the
answer you want.

Yeah, I looked around quite a bit for this already and came up empty.
Just thought I'd post the question as a last resort in case anybody
had an idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top