Sign in to follow this  
BeanDog

[.net] Preventing multiple OnSelectionChanged in ListViews

Recommended Posts

BeanDog    1065
In ListViews, the defined behavior is that an OnSelectionChanged event is raised for each item that becomes selected or unselected. This is a problem for my application, because I hit the network each time they select something new in the list. If they highlight fifty items and then click somewhere, I end up doing fifty round-trips on the network when I only want to do one (for the final state of the listview). So the question is, what's the standard workaround? I only want one event. ~BenDilts( void );

Share this post


Link to post
Share on other sites
Etherstar    200
I would associate some sort of variable within the form that acts as a control switch. You could use an int or a bool that changes or increments when the user fires the event handler. It would check the state of that variable and proceed accordingly.

Another option would be to not use that event at all. Add a button to the form that acts as a confirmation. When the user clicks ok, grab the text (or whatever data you want) from the selected item in the listView control and send your data.

Hope this helps.

Share this post


Link to post
Share on other sites
Toolmaker    967
I have to agree with Etherstart: Add a button. It's smart to have a user confirm before accessing the network, esp. in cases where the user must either wait very long OR when alot of data needs to be transmitted.

Toolmaker

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this