Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Long ago (and far away) I wrote a video library application (just for myself), and apart from slight alterations along the way I have recompiled it for each new computer over many years.

A key part is the ListView, I show filtered Icon views of all of my videos etc, so I can categorize them or play/copy them.

On this particular machine (had it about a month now) everything works fine except when I try to select a lot of videos in one go. Click on the first, Shift-click on the last, I can sit here and watch it slowly hi-lighting each of the icons. Even (say) ten icons I can watch for a few seconds before the interface catches up with me.

Try as I might I just can not find a reason why this one operation should be slow.

So I put together another test application, gave it 100 items (just written in code) select the first, shift-select the last, and it trundles through slowly hi-lighting the selected icons.

The only difference between this compile and the one on my old computer is that I am using the newest Visual Studio (went from VS15 to VS17) and it's library of controls, but I am not aware of any upgrades of the controls library.

Do you have a reason or ideas for the slow selection that I could look at?

What I have tried:

In the debug and process loading there is nothing noticeable that suggests excessive CPU or memory use.
Posted
Updated 10-Apr-18 8:27am

1 solution

You could try this (no guarantees):

C#
stView1.SelectedIndexChanged-=listView1_SelectedIndexChanged;
listView1.SuspendLayout();

try
{
 // selection loop
}
finally
{
  listView1.SelectedIndexChanged+=new EventHandler(listView1_SelectedIndexChanged);
  listView1.ResumeLayout();
}
 
Share this answer
 
Comments
Nelek 10-Apr-18 15:08pm    
Hi John. OP wrote in a non solution below:
------------------
That did work. I just double checked the version running on the old machine, and I did not need to use suspendLayout on that.

Something must have changed between the versions, but now I know what it is I can work with it.

Thank you John.
-------------

Just in case

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900