Jump to content
Harry Bego

TListView won't clear selection

Recommended Posts

I have a TListView, report style, with MultiSelect == true; after selecting multiple items, pressing VK_DOWN does not correctly clear the selection. It visually unselects the items, and unsets their Selected properties. However, pressing Shift + Click includes the 'old' items in the selection.

 

Clicking an item does correctly clear the selection.

The listview is subclassed, but the default procedure is called correctly (I think). I've tried various ways to clear the selection but somehow the listview remembers. The only way I can make it forget is to clear and reload it.

 

Am I missing something? Thank you for any clues!

Share this post


Link to post

Thank you. I did test with a basic TListView and that works fine.

 

There's a lot going on. It uses a home-brewn virtual list; I'm afraid it may be the subclassing. But I'm also using an TApplicationEventsShortCut to dispatch keyboard events.

 

I still hope it is something simple. Rebuilding it from the ground up will take two months. 

 

Share this post


Link to post

Solved! It turned out that one of the cases in a switch statement processing arrow keys did not call the default proc where it should, so the Selected property was not unset. 

 

Moral of story: if a subclassed window procedure shows incorrect default behavior, you're probably not calling the default procedure. 

 

 

Share this post


Link to post

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

×