ListView SelectedIndexChanged firing twice

  • Thread starter Thread starter Jared
  • Start date Start date
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
 
You need to provide some more information
What exactly are you doing to see this behaviour?


/claes
 
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.
}
 
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.
 
Back
Top