views:

155

answers:

1

I realize there are a ton of questions floating around the internet about reducing flicker in Windows Forms applications. After copious experimentation, I found that the solution in my particular case was quite straightforward: setting the Control.DoubleBuffered property to true for the controls that were exhibiting flicker. I accomplished this by simply deriving from the necessary control classes (in my case, from ListView to DoubleBufferedListView and from DataGridView to DoubleBufferedDataGridView).

The primary culprit in the app I am working on is a DataGridView which updates many of its cells on the Tick event of a Windows.Forms.Timer object. Before enabling double buffering, the grid would flicker slightly (not too bad, but enough to be noticeable) on most updates. After enabling double buffering, the flicker went away.

However, I'm talking about my development machine here. Unfortunately, this app is actually run by end users via a Remote Desktop connection, which I learned from this blog post by Raymond Chen means I should not use double buffering.

My question, then, is: what should I use? Chen suggests switching between a double buffered approach on local machines and the traditional non-double buffered approach on remote desktop connections; but in that case the end users of this app will still experience the flicker. Is this simply unavoidable?

For the record: this is not a simple matter of calling BeginUpdate/EndUpdate (already doing that on ListBox and ListView controls) or SuspendLayout/ResumeLayout (already doing that for the DataGridView control as well, although I don't think that's even particularly important since, as I said, I'm just updating the values in certain cells).

Maybe a flicker-free remote desktop app is simply impossible?

+1  A: 

In the category "worth a try": Set the flag AllPaintingInWmPaint on the control, or override OnPaintBackground as suggested here: http://alt.pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html

This would help to get the background paint closer in time to foreground paint. This will improve that chance that they will be sent simultaneously from client to server.

jdv