Since implementing crossfading of tracks in Karaokidex, I’ve indicated the crossfading by gradually fading out the background colour of the first track’s row in the playlist DataGridView and fading in the background colour of the second track’s row. This caused a really annoying flickering.

The problem is the DataGridView is not double-buffered by default, nor is there any visible property on the DataGridView object to set it as double-buffered.

Google to the rescue!

Thanks to the guys at StackOverflow.com for this elegant solution that uses reflection rather than defining a custom class.

typeof(DataGridView).InvokeMember(
   "DoubleBuffered",
   BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
   null,
   myDataGridViewObject,
   new object[] { true });

[Via: stackoverflow]

Leave a Reply

(required)

(required)