Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To end this question, here is a helper class that should be called when the form is loading for each ListView or any other ListView's derived control in your form. Thanks to "Brian Gillespie" for giving the solution.</p> <pre><code>public enum ListViewExtendedStyles { /// &lt;summary&gt; /// LVS_EX_GRIDLINES /// &lt;/summary&gt; GridLines = 0x00000001, /// &lt;summary&gt; /// LVS_EX_SUBITEMIMAGES /// &lt;/summary&gt; SubItemImages = 0x00000002, /// &lt;summary&gt; /// LVS_EX_CHECKBOXES /// &lt;/summary&gt; CheckBoxes = 0x00000004, /// &lt;summary&gt; /// LVS_EX_TRACKSELECT /// &lt;/summary&gt; TrackSelect = 0x00000008, /// &lt;summary&gt; /// LVS_EX_HEADERDRAGDROP /// &lt;/summary&gt; HeaderDragDrop = 0x00000010, /// &lt;summary&gt; /// LVS_EX_FULLROWSELECT /// &lt;/summary&gt; FullRowSelect = 0x00000020, /// &lt;summary&gt; /// LVS_EX_ONECLICKACTIVATE /// &lt;/summary&gt; OneClickActivate = 0x00000040, /// &lt;summary&gt; /// LVS_EX_TWOCLICKACTIVATE /// &lt;/summary&gt; TwoClickActivate = 0x00000080, /// &lt;summary&gt; /// LVS_EX_FLATSB /// &lt;/summary&gt; FlatsB = 0x00000100, /// &lt;summary&gt; /// LVS_EX_REGIONAL /// &lt;/summary&gt; Regional = 0x00000200, /// &lt;summary&gt; /// LVS_EX_INFOTIP /// &lt;/summary&gt; InfoTip = 0x00000400, /// &lt;summary&gt; /// LVS_EX_UNDERLINEHOT /// &lt;/summary&gt; UnderlineHot = 0x00000800, /// &lt;summary&gt; /// LVS_EX_UNDERLINECOLD /// &lt;/summary&gt; UnderlineCold = 0x00001000, /// &lt;summary&gt; /// LVS_EX_MULTIWORKAREAS /// &lt;/summary&gt; MultilWorkAreas = 0x00002000, /// &lt;summary&gt; /// LVS_EX_LABELTIP /// &lt;/summary&gt; LabelTip = 0x00004000, /// &lt;summary&gt; /// LVS_EX_BORDERSELECT /// &lt;/summary&gt; BorderSelect = 0x00008000, /// &lt;summary&gt; /// LVS_EX_DOUBLEBUFFER /// &lt;/summary&gt; DoubleBuffer = 0x00010000, /// &lt;summary&gt; /// LVS_EX_HIDELABELS /// &lt;/summary&gt; HideLabels = 0x00020000, /// &lt;summary&gt; /// LVS_EX_SINGLEROW /// &lt;/summary&gt; SingleRow = 0x00040000, /// &lt;summary&gt; /// LVS_EX_SNAPTOGRID /// &lt;/summary&gt; SnapToGrid = 0x00080000, /// &lt;summary&gt; /// LVS_EX_SIMPLESELECT /// &lt;/summary&gt; SimpleSelect = 0x00100000 } public enum ListViewMessages { First = 0x1000, SetExtendedStyle = (First + 54), GetExtendedStyle = (First + 55), } /// &lt;summary&gt; /// Contains helper methods to change extended styles on ListView, including enabling double buffering. /// Based on Giovanni Montrone's article on &lt;see cref="http://www.codeproject.com/KB/list/listviewxp.aspx"/&gt; /// &lt;/summary&gt; public class ListViewHelper { private ListViewHelper() { } [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern int SendMessage(IntPtr handle, int messg, int wparam, int lparam); public static void SetExtendedStyle(Control control, ListViewExtendedStyles exStyle) { ListViewExtendedStyles styles; styles = (ListViewExtendedStyles)SendMessage(control.Handle, (int)ListViewMessages.GetExtendedStyle, 0, 0); styles |= exStyle; SendMessage(control.Handle, (int)ListViewMessages.SetExtendedStyle, 0, (int)styles); } public static void EnableDoubleBuffer(Control control) { ListViewExtendedStyles styles; // read current style styles = (ListViewExtendedStyles)SendMessage(control.Handle, (int)ListViewMessages.GetExtendedStyle, 0, 0); // enable double buffer and border select styles |= ListViewExtendedStyles.DoubleBuffer | ListViewExtendedStyles.BorderSelect; // write new style SendMessage(control.Handle, (int)ListViewMessages.SetExtendedStyle, 0, (int)styles); } public static void DisableDoubleBuffer(Control control) { ListViewExtendedStyles styles; // read current style styles = (ListViewExtendedStyles)SendMessage(control.Handle, (int)ListViewMessages.GetExtendedStyle, 0, 0); // disable double buffer and border select styles -= styles &amp; ListViewExtendedStyles.DoubleBuffer; styles -= styles &amp; ListViewExtendedStyles.BorderSelect; // write new style SendMessage(control.Handle, (int)ListViewMessages.SetExtendedStyle, 0, (int)styles); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload