tags:

views:

82

answers:

4

hi. i am facing a problem.

i have a list view which is in detail form..

it has large quantity of data to display. and the data is continuously updating after each second.

in current situation list view is flickering. how can i solve this issue

+2  A: 

Instead of just refreshing the page to pull in the new content maybe you could use jquery and JSON?

So use jquery to send the request for more information every X seconds that calls an ashx page. The ashx page grabs the data from your database and then return you should return the result values as json so jquery can easily parse result and display onto the screen.

Great tutorial of doing this type of thing using jquery, c# and web services below:

Encosia - using jquery to consume aspnet

jquery json documentation

Hope that's some help to you.

EDIT: My answer assumed you were using asp.net web forms. I've never used win forms (apart from my old vb 6 days) so not sure if you can work with jquery or not there.

Richard Reddy
A: 

A part of the flickering in WinForms application can be solved by doublebuffering the form and / or controls within it. See also: Anti Flicker Graphics using Double Buffering

SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);

Alternatively, look into the Control.DoubleBuffered property:

Webleeuw
+1  A: 

In WinForms to prevent this flicker effect, you need to user a BackgroundWorker object to run your process in a separate thread. Then, after an acceptable interval, use the BackgroundWorker's ReportProgress to update the list appropriately.

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx http://www.dotneat.net/2009/02/10/BackgroundworkerExample.aspx http://dotnetperls.com/backgroundworker

This will allow you to call the list's Refresh() method regularly without forcing the flicker since the processes will be in different threads.

Joel Etherton
Don't you think that the list flickers simply because it is large and not because there are two threads, do you?
Igor Korkhov
@Igor - It's always possible, but I have a couple of WinForms apps that have text boxes that are large. Moving the process to another thread and calling the Refresh() method cleared it up for me. The DoubleBuffering method listed by the other user is also a good method for alleviating the problem. I just thought I would post an alternative idea.
Joel Etherton
@Joel Etherton: Sorry for possible misunderstanding, when I said 'large' I meant 'a *very* big number of lines', and in that case it takes significant time to redraw the listbox. I think it will flicker if you just call Refresh() repeatedly even without adding lines.
Igor Korkhov
@Igor - I think it flickers because the number of lines combined with the Refresh() being on the same thread as the one performing the load. If you move the load off the thread, the Refresh() is much more efficient. It's still possible you'll get a flicker if it is that enormous, but if you have that I don't think even the DoubleBuffer solution will work.
Joel Etherton
A: 

Use a FastObjectListView from the ObjectListView project -- a wrapper around the .NET WinForms ListView control. The fast version is a virtual list that uses double buffering to give flicker free updates.

I've used it for listviews with more than 50,000 objects and the update time is less than 0.5 seconds (on a mid-range laptop).

BUT even with almost instant updates, your users are going to have a hard time using a control that changes its contents every seconds.

Grammarian