public static void SetSortIcon(this ListView listViewControl, int columnIndex, SortOrder order)
        {
            IntPtr hWnd = ListViewExtensions.SendMessage(listViewControl.Handle, 4127U, IntPtr.Zero, IntPtr.Zero);

            for (int index = 0; index <= listViewControl.Columns.Count - 1; ++index)
            {
                IntPtr wParam = new IntPtr(index);
                ListViewExtensions.HDITEM lParam = new ListViewExtensions.HDITEM()
                {
                    mask = ListViewExtensions.HDITEM.Mask.Format
                };
                if (ListViewExtensions.SendMessage(hWnd, 4619U, wParam, ref lParam) == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }
                if (order != SortOrder.None && index == columnIndex)
                {
                    switch (order)
                    {
                    case SortOrder.Ascending:
                        lParam.fmt &= ~ListViewExtensions.HDITEM.Format.SortDown;
                        lParam.fmt |= ListViewExtensions.HDITEM.Format.SortUp;
                        break;

                    case SortOrder.Descending:
                        lParam.fmt &= ~ListViewExtensions.HDITEM.Format.SortUp;
                        lParam.fmt |= ListViewExtensions.HDITEM.Format.SortDown;
                        break;
                    }
                }
                else
                {
                    lParam.fmt &= ~(ListViewExtensions.HDITEM.Format.SortDown | ListViewExtensions.HDITEM.Format.SortUp);
                }
                if (ListViewExtensions.SendMessage(hWnd, 4620U, wParam, ref lParam) == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }
            }
        }
 public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, ref ListViewExtensions.HDITEM lParam);