ListView SelectedIndexChanged firing twice

J

Jared

Hi,

I have a Listview that is firing an event twice and both time the
selecteditems count is = 1

In the call stack there is form.show
 
C

Claes Bergefall

You need to provide some more information
What exactly are you doing to see this behaviour?


/claes
 
N

Norman Yuan

I think, this behavior is by design. That is, when you click an item in
listview, if thre is a previously selected one, that one gets deselected
first, then the clicked one gets selected. This behavior puzzled me when I
used listview first time in .NET. In old VB5/6, there is an event ItemClick,
which is not available in .NET listview anymore.

So, when I want to get a selected item in listview's SelectedIncdexChanged
event handler, I do this:

private void MyListView_SelectedIndexChanged(object sender.....)
{
if (MyListView.SelectedItems.Count==0) return;

//Then do whatever here.
}
 
J

Jared

Only thing I can think of Is loading the Listview grid while form is not
visible.

I now have genric routine called from a Click event. I successfully have
used SLI event on many other form with the normal double firing.
 

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