This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
fuss:csharp [2019/08/22 07:32] – [Recursive] office | fuss:csharp [2021/05/08 03:22] – [Iterative] office | ||
---|---|---|---|
Line 1786: | Line 1786: | ||
</ | </ | ||
+ | ====== Enable Double Buffering for Controls ====== | ||
+ | |||
+ | Some window forms controls do not expose the double buffering property such that the following static extension method will attempt to enable double buffering and return true on success or false otherwise. | ||
+ | |||
+ | <code csharp> | ||
+ | /// < | ||
+ | /// Enable double buffering for an arbitrary control. | ||
+ | /// </ | ||
+ | /// <param name=" | ||
+ | /// < | ||
+ | /// < | ||
+ | public static bool SetDoubleBuffered(this Control control) | ||
+ | { | ||
+ | if (SystemInformation.TerminalServerSession) | ||
+ | { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | var dgvType = control.GetType(); | ||
+ | var pi = dgvType.GetProperty(" | ||
+ | BindingFlags.Instance | BindingFlags.NonPublic); | ||
+ | if (pi == null) | ||
+ | { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | pi.SetValue(control, | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Enabling double buffering can be particularly beneficial for '' | ||