Ejemplo n.º 1
0
        public static void ListView_SetHeaderSortIndicator(IntPtr hWnd, Int32 columnIdx, System.Windows.Forms.SortOrder order)
        {
            IntPtr header     = ListView_GetHeader(hWnd);
            Int32  nofColumns = Header_GetItemCount(header);

            for (int i = 0; i < nofColumns; i++)
            {
                HdItem item = new HdItem();
                item.mask = HDI_FORMAT;
                item      = Header_GetItem(header, i, item);

                if (i == columnIdx)
                {
                    item.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);

                    if (order == SortOrder.Ascending)
                    {
                        item.fmt |= HDF_SORTUP;
                    }
                    else if (order == SortOrder.Descending)
                    {
                        item.fmt |= HDF_SORTDOWN;
                    }
                }
                else
                {
                    item.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
                }

                Header_SetItem(header, i, ref item);
            }
        }
Ejemplo n.º 2
0
        private static void Header_SetItem(IntPtr headerHWnd, Int32 columnIndex, ref HdItem info)
        {
            Int32  size = Marshal.SizeOf(info);
            IntPtr p    = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(info, p, true);

            IntPtr result = SendMessage(headerHWnd, HDM_SETITEM, new UIntPtr((uint)columnIndex), p);

            Marshal.FreeHGlobal(p);
        }
Ejemplo n.º 3
0
        private static HdItem Header_GetItem(IntPtr headerHWnd, Int32 columnIndex, HdItem info)
        {
            Int32  size = Marshal.SizeOf(info);
            IntPtr p    = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(info, p, true);

            IntPtr result = SendMessage(headerHWnd, HDM_GETITEM, new UIntPtr((uint)columnIndex), p);

            HdItem updated = (HdItem)Marshal.PtrToStructure(p, typeof(HdItem));

            Marshal.FreeHGlobal(p);

            return(updated);
        }