ListViews SelectedIndexChanged Event Options

A

ArunDhaJ

Hi Friends,

I'm using .Net1.1.
The SelectedIndexChanged event is generated twice when i change the
selection. I think this is because the event is triggered when an
item
loses focus and the other item gains focus.
I want this event to be triggered only once.


Plz help me in solving this problem...


Thanks in advance....


Regards
ArunDhaJ
 
M

Morten Wennevik [C# MVP]

Hi Friends,

I'm using .Net1.1.
The SelectedIndexChanged event is generated twice when i change the
selection. I think this is because the event is triggered when an
item
loses focus and the other item gains focus.
I want this event to be triggered only once.


Plz help me in solving this problem...


Thanks in advance....


Regards
ArunDhaJ

A solution to secondary events is using a flag or similar that lets you detect if the event has been handled or not.
 
S

Stanimir Stoyanov

ArunDhaJ said:
The SelectedIndexChanged event is generated twice when i change the
selection. I think this is because the event is triggered when an
item
loses focus and the other item gains focus.
I want this event to be triggered only once.

By default the event is raised only once, when the new item gains focus, so
this is unlikely to be the cause. You can check if you have manually
attached a handler to the event. Removing it would be the best solution.

EventHandlers are attached using the syntax: "listView.SelectedIndexChanged
+= new EventHandler(...);".

Best Regards,
Stanimir Stoyanov
www.stoyanoff.info | www.aeroxp.org
 

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