Ejemplo n.º 1
0
        // We should clear the sort glyph on the old column
        private void ShowSortGlyph(int lastSortedColumn, int columnToSort)
        {
            // Get the handle of the ListView header
            IntPtr hHeader    = Win32NativeMethods.SendMessage(lvRestorePoints.Handle, Win32NativeMethods.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
            IntPtr newColumn  = new IntPtr(columnToSort);
            IntPtr prevColumn = new IntPtr(lastSortedColumn);

            Win32NativeMethods.HDITEM hdi;
            IntPtr rtn;

            // If the last sorted column exists
            if (lastSortedColumn != -1 && lastSortedColumn != columnToSort)
            {
                hdi      = new Win32NativeMethods.HDITEM();
                hdi.mask = Win32NativeMethods.HDI_FORMAT;
                rtn      = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_GETITEM, prevColumn, ref hdi);
                hdi.fmt &= ~Win32NativeMethods.HDF_SORTDOWN & ~Win32NativeMethods.HDF_SORTUP;

                // Clear the sort glyph
                rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_SETITEM, prevColumn, ref hdi);
            }

            hdi      = new Win32NativeMethods.HDITEM();
            hdi.mask = Win32NativeMethods.HDI_FORMAT;
            rtn      = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_GETITEM, newColumn, ref hdi);
            hdi.fmt |= lvRestorePoints.Sorting == SortOrder.Ascending ? Win32NativeMethods.HDF_SORTUP : Win32NativeMethods.HDF_SORTDOWN;

            // Send message to the column header to show the sort glyph
            rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_SETITEM, newColumn, ref hdi);
            lastSortedColumn = columnToSort;
        }
Ejemplo n.º 2
0
        // We should clear the sort glyph on the old column
        private void ShowSortGlyph(int lastSortedColumn, int columnToSort)
        {
            // Get the handle of the ListView header
            IntPtr hHeader = Win32NativeMethods.SendMessage(lvRestorePoints.Handle, Win32NativeMethods.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
            IntPtr newColumn = new IntPtr(columnToSort);
            IntPtr prevColumn = new IntPtr(lastSortedColumn);
            Win32NativeMethods.HDITEM hdi;
            IntPtr rtn;

            // If the last sorted column exists
            if (lastSortedColumn != -1 && lastSortedColumn != columnToSort)
            {
                hdi = new Win32NativeMethods.HDITEM();
                hdi.mask = Win32NativeMethods.HDI_FORMAT;
                rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_GETITEM, prevColumn, ref hdi);
                hdi.fmt &= ~Win32NativeMethods.HDF_SORTDOWN & ~Win32NativeMethods.HDF_SORTUP;

                // Clear the sort glyph
                rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_SETITEM, prevColumn, ref hdi);
            }

            hdi = new Win32NativeMethods.HDITEM();
            hdi.mask = Win32NativeMethods.HDI_FORMAT;
            rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_GETITEM, newColumn, ref hdi);
            hdi.fmt |= lvRestorePoints.Sorting == SortOrder.Ascending ? Win32NativeMethods.HDF_SORTUP : Win32NativeMethods.HDF_SORTDOWN;

            // Send message to the column header to show the sort glyph
            rtn = Win32NativeMethods.SendMessageItem(hHeader, Win32NativeMethods.HDM_SETITEM, newColumn, ref hdi);
            lastSortedColumn = columnToSort;
        }