Connecting Tech Pros Worldwide Forums | Help | Site Map

how to avoid flickering in listview?

Joaquin Grech
Guest
 
Posts: n/a
#1: Nov 15 '05
Hi

I did alot of research on this on the web and msdn and I couldn't find
anything.

I have a listview showing as a grid (table looking, with rows and columns
and no images at all, only text). I get the information to display on the
listview from the network and I add items often and stuff.

But more than adding items, what worries me is the step of modifying items.
I change the text of one of the columns for every row every 2 seconds.
Something like: "Time to next update: X seconds"
and that text changes every 2 seconds.

Every time i change the text, the item flickers. When I have 50 rows the
screen looks like a discoteque so it is not good.

I found lot of examples on avoiding flickering but most of them don't work,
are not correctly implemented or are thought for other
circunstances/controls.

I found that I could extend the listview control and add this to my
constructor:
this.SetStyle(ControlStyles.DoubleBuffer |

ControlStyles.UserPaint |

ControlStyles.AllPaintingInWmPaint,

true);

this.UpdateStyles();



that should enable double buffering, but i don't know how to draw the items
manually from there.



Any help would be greatly appreciated.



Joaquin Grech





Alan Pretre
Guest
 
Posts: n/a
#2: Nov 15 '05

re: how to avoid flickering in listview?


"Joaquin Grech" <creative1@bigfoot.com> wrote in message
news:uVYNdYvoDHA.2512@TK2MSFTNGP09.phx.gbl...[color=blue]
> Every time i change the text, the item flickers. When I have 50 rows the
> screen looks like a discoteque so it is not good.[/color]

See BeginUpdate() and EndUpdate().

-- Alan


Joaquin Grech
Guest
 
Posts: n/a
#3: Nov 15 '05

re: how to avoid flickering in listview?


I just posted an answer to that... it doesn't work

"Alan Pretre" <no@spam> wrote in message
news:Oebz5avoDHA.688@TK2MSFTNGP10.phx.gbl...[color=blue]
> "Joaquin Grech" <creative1@bigfoot.com> wrote in message
> news:uVYNdYvoDHA.2512@TK2MSFTNGP09.phx.gbl...[color=green]
> > Every time i change the text, the item flickers. When I have 50 rows the
> > screen looks like a discoteque so it is not good.[/color]
>
> See BeginUpdate() and EndUpdate().
>
> -- Alan
>
>[/color]


Joaquin Grech
Guest
 
Posts: n/a
#4: Nov 15 '05

re: how to avoid flickering in listview?


Just to make myself clear, I call this every 2 seconds:

listView1.BeginUpdate();

foreach (ListViewItem aux in listView1.Items)

{

aux.SubItems[3].Text="some changing text here";

}

listView1.EndUpdate();



I thought this would stop the flickering by using beginupdate/endupdate but
the flickering is still there... any ideas?



Joaquin Grech

"Joaquin Grech" <creative1@bigfoot.com> wrote in message
news:uVYNdYvoDHA.2512@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi
>
> I did alot of research on this on the web and msdn and I couldn't find
> anything.
>
> I have a listview showing as a grid (table looking, with rows and columns
> and no images at all, only text). I get the information to display on the
> listview from the network and I add items often and stuff.
>
> But more than adding items, what worries me is the step of modifying[/color]
items.[color=blue]
> I change the text of one of the columns for every row every 2 seconds.
> Something like: "Time to next update: X seconds"
> and that text changes every 2 seconds.
>
> Every time i change the text, the item flickers. When I have 50 rows the
> screen looks like a discoteque so it is not good.
>
> I found lot of examples on avoiding flickering but most of them don't[/color]
work,[color=blue]
> are not correctly implemented or are thought for other
> circunstances/controls.
>
> I found that I could extend the listview control and add this to my
> constructor:
> this.SetStyle(ControlStyles.DoubleBuffer |
>
> ControlStyles.UserPaint |
>
> ControlStyles.AllPaintingInWmPaint,
>
> true);
>
> this.UpdateStyles();
>
>
>
> that should enable double buffering, but i don't know how to draw the[/color]
items[color=blue]
> manually from there.
>
>
>
> Any help would be greatly appreciated.
>
>
>
> Joaquin Grech
>
>
>
>[/color]


Cybertof
Guest
 
Posts: n/a
#5: Nov 15 '05

re: how to avoid flickering in listview?


Maybe

listView1.SuspendLayout();
....
....
listView1.ResumeLayout();

?

Cybertof.


In article <eUT9XevoDHA.2592@TK2MSFTNGP10.phx.gbl>, creative1
@bigfoot.com says...[color=blue]
> Just to make myself clear, I call this every 2 seconds:
>
> listView1.BeginUpdate();
>
> foreach (ListViewItem aux in listView1.Items)
>
> {
>
> aux.SubItems[3].Text="some changing text here";
>
> }
>
> listView1.EndUpdate();
>
>
>
> I thought this would stop the flickering by using beginupdate/endupdate but
> the flickering is still there... any ideas?
>[/color]
Joaquin Grech
Guest
 
Posts: n/a
#6: Nov 15 '05

re: how to avoid flickering in listview?


nice try, but nope

"Cybertof" <cybertof2003nospam@gmx.net> wrote in message
news:MPG.1a120942de2127c69896c3@msnews.microsoft.c om...[color=blue]
> Maybe
>
> listView1.SuspendLayout();
> ...
> ...
> listView1.ResumeLayout();
>
> ?
>
> Cybertof.
>
>
> In article <eUT9XevoDHA.2592@TK2MSFTNGP10.phx.gbl>, creative1
> @bigfoot.com says...[color=green]
> > Just to make myself clear, I call this every 2 seconds:
> >
> > listView1.BeginUpdate();
> >
> > foreach (ListViewItem aux in listView1.Items)
> >
> > {
> >
> > aux.SubItems[3].Text="some changing text here";
> >
> > }
> >
> > listView1.EndUpdate();
> >
> >
> >
> > I thought this would stop the flickering by using beginupdate/endupdate[/color][/color]
but[color=blue][color=green]
> > the flickering is still there... any ideas?
> >[/color][/color]


Joaquin Grech
Guest
 
Posts: n/a
#7: Nov 15 '05

re: how to avoid flickering in listview?


should i give up on this?

I got tons of samples on the web using lockwindowupdate, setstyle and other
wonderful stuff like handleing WM_PAINT and erasebg... nothing worked.

Anyone has a code that would make something as simple as this on a listview
work without flickering?

foreach (ListViewItem aux in listView1.Items)

{

aux.SubItems[3].Text="some changing text here";

}

looks simple? well... i found 250 posts from people with similar problems
and no one single one answered right :(

I guess the right solution would be using
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);

and drawing all the list items manually, but I have no idea how to do this.

Any code would be greatly appreciated.

Joaquin Grech


"Joaquin Grech" <creative1@bigfoot.com> wrote in message
news:uVYNdYvoDHA.2512@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi
>
> I did alot of research on this on the web and msdn and I couldn't find
> anything.
>
> I have a listview showing as a grid (table looking, with rows and columns
> and no images at all, only text). I get the information to display on the
> listview from the network and I add items often and stuff.
>
> But more than adding items, what worries me is the step of modifying[/color]
items.[color=blue]
> I change the text of one of the columns for every row every 2 seconds.
> Something like: "Time to next update: X seconds"
> and that text changes every 2 seconds.
>
> Every time i change the text, the item flickers. When I have 50 rows the
> screen looks like a discoteque so it is not good.
>
> I found lot of examples on avoiding flickering but most of them don't[/color]
work,[color=blue]
> are not correctly implemented or are thought for other
> circunstances/controls.
>
> I found that I could extend the listview control and add this to my
> constructor:
> this.SetStyle(ControlStyles.DoubleBuffer |
>
> ControlStyles.UserPaint |
>
> ControlStyles.AllPaintingInWmPaint,
>
> true);
>
> this.UpdateStyles();
>
>
>
> that should enable double buffering, but i don't know how to draw the[/color]
items[color=blue]
> manually from there.
>
>
>
> Any help would be greatly appreciated.
>
>
>
> Joaquin Grech
>
>
>
>[/color]


Closed Thread