A few more tips on customizing ListView

Last time I showed you on how to customize ListView control on WM 6.5 for .NET CF 3.5. Today I am going to show you a few more. They are all based on the same paradigm - changing an extended style of a ListView control. First one is to enable showing grid lines:

/// <summary>

/// Shows grid lines in the listview

/// </summary>

/// <param name="listView">ListView instance</param>

public static void ShowGridLines(this ListView listView)

{

      // Retreive the current extended style

     int currentStyle = SendMessage(listView.Handle,

                           (uint)LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);

    // Assign the LVS_EX_GRIDLINES style

     SendMessage(listView.Handle, (uint)LVM_SETEXTENDEDLISTVIEWSTYLE, 0,

currentStyle | LVS_EX_GRIDLINES);

 }

And the second one is to enable double-buffering. This should reduce flickering when scrolling on changing the focus from one item to another:

  /// <summary>

  /// Enable double-buffering in the listview

  /// </summary>

  /// <param name="listView">ListView instance</param>

  public static void EnableDoubleBuffering(this ListView listView)

  {

        // Retreive the current extended style

        int currentStyle = SendMessage(listView.Handle,

 (uint)LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);

        // Assign the LVS_EX_DOUBLEBUFFER style

        SendMessage(listView.Handle, (uint)LVM_SETEXTENDEDLISTVIEWSTYLE, 0,

currentStyle | LVS_EX_DOUBLEBUFFER);

  }

 Please find the updated ListViewExtender class in the attachments to this post.

ListViewExtention.cs