Displaying a selected ListViewItem

D

Day

Hi~

I'm writing an application that displays a list of files in a ListView
control and updates their status while filtering and copying processes
happen, i.e. - I copy a file, that file's status is displayed as being
transfered. I filter a file, it then shows the result of the
filtering, etc.
The thing is this -
If I use labels to display the "currently worked-on" item, the program
can't keep up the pace for small files since they get copied and
scanned so fast, so the messages coming in from the BackgrounWorkers
just plug up the system.
Is there a way to set the ListView to show the currently selected
ListViewItem, so I can just focus on it as I go along with the copying
and filtering?

Thanks in advance,
~Day
 
O

Oliver Sturm

Hello Day,
Is there a way to set the ListView to show the currently selected
ListViewItem, so I can just focus on it as I go along with the copying
and filtering?

I understood everything about your post right up the point where you ask
the above question. What is the idea you're trying to implement now? Can
you explain in more detail?


Oliver Sturm
 
B

Bruce Wood

Hi~

I'm writing an application that displays a list of files in a ListView
control and updates their status while filtering and copying processes
happen, i.e. - I copy a file, that file's status is displayed as being
transfered. I filter a file, it then shows the result of the
filtering, etc.
The thing is this -
If I use labels to display the "currently worked-on" item, the program
can't keep up the pace for small files since they get copied and
scanned so fast, so the messages coming in from the BackgrounWorkers
just plug up the system.
Is there a way to set the ListView to show the currently selected
ListViewItem, so I can just focus on it as I go along with the copying
and filtering?

Yes, there is an EnsureVisible method, but perhaps what you want is to
rework the communications between your background thread and your UI.

If the small files are being copied and scanned so fast that the user
can't even read the resulting messages, then why show them? Or, stated
another way, does your UI really need to display every single event
coming from the background threads? If the answer is no (which it
probably should be) then why use Invoke to update the UI?

You could, instead, create a common, go-between object that holds the
information about what is currently happening with the background
threads. The background threads update this common object as they
work.

Then the UI just polls it at regular intervals and updates its status
accordingly. Since the UI no longer _has_ to handle every single event
from the background workers, there are no messages to "plug up the
system." If the background workers manage to process three files
before the UI updates again, then the messages will just be skipped.
The user won't notice the difference.

Does that help?
 

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