Blurry Text with C# Listview when reducing flicker
.net, c#, listview, winforms
Solution
I usually do this - reduces flickering when resizing the control. You need to use `BeginUpdate()` / `EndUpdate()` to reduce flickering when adding items in bulk. I don't know what may cause the blurring, so I can't advise about that - updatig your video driver may help but don't hold your hopes high.
[System.ComponentModel.DesignerCategory ( "" )]
public partial class ListViewEx : ListView
{
private const int WM_ERASEBKGND = 0x14;
public ListViewEx ()
{
InitializeComponent ();
// Turn on double buffering.
SetStyle ( ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint, true );
// Enable the OnNotifyMessage to filter out Windows messages.
SetStyle ( ControlStyles.EnableNotifyMessage, true );
}
protected override void OnNotifyMessage ( Message oMsg )
{
// Filter out the WM_ERASEBKGND message to prevent the control
// from erasing the background (and thus avoid flickering.)
if ( oMsg.Msg != WM_ERASEBKGND )
base.OnNotifyMessage ( oMsg );
}
}
Problem
I have a System.Windows.Forms.ListView containing numerous items. It was flickering intolerably (as seems to often be the case) so after some searching I decided to do these 2 things in a "ListViewLessFlicker" class. ``` this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.Opaque, true); ``` DoubleBuffering didn't have much effect even though it's most commonly given as the solution in these topics, but setting the style opaque to true hugely reduced flickering. http://www.virtualdub.org/blog/pivot/entry.php?id=273 However it had a side-effect that I can't seem to find a fix for. When I hover my mouse over an item in the ListView it now makes the text bold and very blurry (this doesn't happen unless opaque is true). Here is a very zoomed in example. If anybody has a fix or knows why it may be doing this I'd love to know!