Пример #1
0
        public static void SetSortIcon(this ifListView ListViewControl, int ColumnIndex, System.Windows.Forms.SortOrder Order)
        {
            IntPtr ColumnHeader = SendMessage(ListViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int ColumnNumber = 0; ColumnNumber <= ListViewControl.Columns.Count - 1; ColumnNumber++)
            {
                IntPtr   ColumnPtr = new IntPtr(ColumnNumber);
                LVCOLUMN lvColumn  = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;
                SendMessageLVCOLUMN(ColumnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);
                if (!(Order == System.Windows.Forms.SortOrder.None) && ColumnNumber == ColumnIndex)
                {
                    switch (Order)
                    {
                    case System.Windows.Forms.SortOrder.Ascending:
                        lvColumn.fmt &= ~HDF_SORTDOWN;
                        lvColumn.fmt |= HDF_SORTUP;
                        break;

                    case System.Windows.Forms.SortOrder.Descending:
                        lvColumn.fmt &= ~HDF_SORTUP;
                        lvColumn.fmt |= HDF_SORTDOWN;
                        break;
                    }
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                }
                SendMessageLVCOLUMN(ColumnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
            }
        }
Пример #2
0
        internal void SetColumnFormat(int columnIndex, ListViewColumnFormat fmtFlag, bool on)
        {
            if (((columnIndex < 0) || ((columnIndex >= 0) && (Columns == null))) || (columnIndex >= Columns.Count))
            {
                throw new ArgumentOutOfRangeException(nameof(columnIndex));
            }

            if (IsHandleCreated)
            {
                var lvc = new LVCOLUMN(ListViewColumMask.Fmt);
                User32.SendMessage(Handle, ListViewMessage.GetColumn, columnIndex, lvc);
                if (on)
                {
                    lvc.Format |= fmtFlag;
                }
                else
                {
                    lvc.Format &= (~fmtFlag);
                }
                if (User32.SendMessage(Handle, ListViewMessage.SetColumn, columnIndex, lvc) == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }
                this.InvalidateHeader();
            }
        }
        public void SetSortIcon(ListView listview)
        {
            IntPtr clmHdr = SendMessage(listview.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int i = 0; i < listview.Columns.Count; i++)
            {
                IntPtr   clmPtr   = new IntPtr(i);
                LVCOLUMN lvColumn = new LVCOLUMN();

                lvColumn.mask = HDI_FORMAT;
                SendMessageLVCOLUMN(clmHdr, HDM_GETITEM, clmPtr, ref lvColumn);

                if (Order != SortOrder.None && i == ColumnToSort)
                {
                    if (Order == SortOrder.Ascending)
                    {
                        lvColumn.fmt &= ~HDF_SORTDOWN;
                        lvColumn.fmt |= HDF_SORTUP;
                    }
                    else
                    {
                        lvColumn.fmt &= ~HDF_SORTUP;
                        lvColumn.fmt |= HDF_SORTDOWN;
                    }
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                }

                SendMessageLVCOLUMN(clmHdr, HDM_SETITEM, clmPtr, ref lvColumn);
            }
        }
        public static void SetSortIcon(this ColumnHeader column, SortOrder order)
        {
            ListView listView = column.ListView;
            IntPtr columnHeader = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int i = 0; i <= listView.Columns.Count - 1; i++)
            {
                IntPtr ColumnPtr = new IntPtr(i);
                LVCOLUMN lvColumn = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;
                SendMessage(columnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);

                if (!(order == SortOrder.None) && i == column.Index)
                {
                    switch (order)
                    {
                        case SortOrder.Ascending:
                            lvColumn.fmt &= ~HDF_SORTDOWN;
                            lvColumn.fmt |= HDF_SORTUP;
                            break;
                        case SortOrder.Descending:
                            lvColumn.fmt &= ~HDF_SORTUP;
                            lvColumn.fmt |= HDF_SORTDOWN;
                            break;
                    }
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                }

                SendMessage(columnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
            }
        }
        public static void SetSortIcon(this System.Windows.Forms.ListView ListViewControl, int ColumnIndex, System.Windows.Forms.SortOrder Order)
        {
            IntPtr ColumnHeader = SendMessage(ListViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int ColumnNumber = 0; ColumnNumber <= ListViewControl.Columns.Count - 1; ColumnNumber++)
            {
                IntPtr ColumnPtr = new IntPtr(ColumnNumber);
                LVCOLUMN lvColumn = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;
                SendMessageLVCOLUMN(ColumnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);

                if (!(Order == System.Windows.Forms.SortOrder.None) && ColumnNumber == ColumnIndex)
                {
                    switch (Order)
                    {
                        case System.Windows.Forms.SortOrder.Ascending:
                            lvColumn.fmt &= ~HDF_SORTDOWN;
                            lvColumn.fmt |= HDF_SORTUP;
                            break;
                        case System.Windows.Forms.SortOrder.Descending:
                            lvColumn.fmt &= ~HDF_SORTUP;
                            lvColumn.fmt |= HDF_SORTDOWN;
                            break;
                    }
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                }

                SendMessageLVCOLUMN(ColumnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
            }
        }
Пример #6
0
        public static void SetSortIcon(this ListView listView, int columnIndex, SortOrder order)
        {
            var columnHeader = (HWND)SendMessage(listView.Handle, (uint)ListViewMessage.LVM_GETHEADER);

            for (var columnNumber = 0; columnNumber <= listView.Columns.Count - 1; columnNumber++)
            {
                // Get current ListView column info
                var lvcol = new LVCOLUMN(ListViewColumMask.LVCF_FMT);
                SendMessage(listView.Handle, ListViewMessage.LVM_GETCOLUMN, columnNumber, lvcol);

                // Get current header info
                var hditem = new HDITEM(HeaderItemMask.HDI_FORMAT | HeaderItemMask.HDI_DI_SETITEM);
                SendMessage(columnHeader, HeaderMessage.HDM_GETITEM, columnNumber, hditem);

                // Update header with column info
                hditem.Format |= (HeaderItemFormat)((uint)lvcol.Format & 0x1001803);
                if ((lvcol.Format & ListViewColumnFormat.LVCFMT_NO_TITLE) == 0)
                {
                    hditem.ShowText = true;
                }

                // Set header image info
                if (order != SortOrder.None && columnNumber == columnIndex)
                {
                    hditem.ImageDisplay = (order == SortOrder.Descending) ? HeaderItemImageDisplay.DownArrow : HeaderItemImageDisplay.UpArrow;
                }
                else
                {
                    hditem.ImageDisplay = HeaderItemImageDisplay.None;
                }

                // Update header
                SendMessage(columnHeader, HeaderMessage.HDM_SETITEM, columnNumber, hditem);
            }
        }
Пример #7
0
        public static void SetSortIcon(this ColumnHeader column, SortOrder order)
        {
            ListView listView     = column.ListView;
            IntPtr   columnHeader = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int i = 0; i <= listView.Columns.Count - 1; i++)
            {
                IntPtr   ColumnPtr = new IntPtr(i);
                LVCOLUMN lvColumn  = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;
                SendMessage(columnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);

                if (!(order == SortOrder.None) && i == column.Index)
                {
                    switch (order)
                    {
                    case SortOrder.Ascending:
                        lvColumn.fmt &= ~HDF_SORTDOWN;
                        lvColumn.fmt |= HDF_SORTUP;
                        break;

                    case SortOrder.Descending:
                        lvColumn.fmt &= ~HDF_SORTUP;
                        lvColumn.fmt |= HDF_SORTDOWN;
                        break;
                    }
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                }

                SendMessage(columnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
            }
        }
    private void SetDropdown(int column, bool enable)
    {
        LVCOLUMN lvc = new LVCOLUMN();

        lvc.mask = LVCF_FMT;
        lvc.fmt  = enable ? LVCFMT_SPLITBUTTON : 0;
        IntPtr res = SendMessage(this.Handle, LVM_SETCOLUMN, (IntPtr)column, ref lvc);
    }
Пример #9
0
        public int ListView_GetColumnPos(System.Windows.Forms.ListView listView, int columnIndex)
        {
            LVCOLUMN lvCol = new LVCOLUMN();

            lvCol.mask = LVCF_ORDER;
            HandleRef hWnd = new HandleRef(listView, listView.Handle);

            SendMessage(hWnd, LVM_GETCOLUMN, columnIndex, out lvCol);
            return(lvCol.iOrder);
        }
Пример #10
0
        /// <summary>Sets a list view header column to display as a split button or not.</summary>
        /// <param name="listView">The list view.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="enable">if set to <see langword="true"/> show the column header as a split button.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">columnIndex</exception>
        public static void SetColumnDropDown(this ListView listView, int columnIndex, bool enable)
        {
            if (((columnIndex < 0) || ((columnIndex >= 0) && (listView.Columns == null))) || (columnIndex >= listView.Columns.Count))
            {
                throw new ArgumentOutOfRangeException(nameof(columnIndex));
            }

            if (listView.IsHandleCreated)
            {
                var lvc = new LVCOLUMN(ListViewColumMask.LVCF_FMT);
                var hr  = listView.Handle;
                SendMessage(hr, ListViewMessage.LVM_GETCOLUMN, columnIndex, lvc);
                lvc.Format = lvc.Format.SetFlags(ListViewColumnFormat.LVCFMT_SPLITBUTTON, enable);
                SendMessage(hr, ListViewMessage.LVM_SETCOLUMN, columnIndex, lvc);
                listView.InvalidateHeader();
            }
        }
Пример #11
0
		public static void AddDefaultColumns(this ShellView shellView, bool isFirstOnly = false, bool excludeFirst = false) {
			if (!excludeFirst) {
				var column = new LVCOLUMN() { cx = 75, iSubItem = 0, pszText = "Name", fmt = LVCFMT.LEFT };
				column.mask = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_MINWIDTH;
				User32.SendMessage(shellView.LVHandle, BExplorer.Shell.Interop.MSG.LVM_INSERTCOLUMN, 0, ref column);

				var collumn = column.ToCollumns(new PROPERTYKEY() { fmtid = Guid.Parse("B725F130-47EF-101A-A5F1-02608C9EEBAC"), pid = 10 }, typeof(String), false, 200);
				collumn.ID = "A0";
				shellView.Collumns.Add(collumn);
			}

			if (!isFirstOnly) {
				if (!shellView.Collumns.Any(c => c.ID == "A182")) {
					var column2 = new LVCOLUMN() { cx = 100, iSubItem = 1, pszText = "Type", fmt = LVCFMT.LEFT };
					column2.mask = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
					User32.SendMessage(shellView.LVHandle, BExplorer.Shell.Interop.MSG.LVM_INSERTCOLUMN, 1, ref column2);

					var columnType = column2.ToCollumns(new PROPERTYKEY() { fmtid = Guid.Parse("B725F130-47EF-101A-A5F1-02608C9EEBAC"), pid = 4 }, typeof(Type), false, 150);
					columnType.ID = "A182";
					shellView.Collumns.Add(columnType);
				}

				if (!shellView.Collumns.Any(c => c.ID == "A1")) {
					var column3 = new LVCOLUMN() { cx = 100, iSubItem = 2, pszText = "Size", fmt = LVCFMT.RIGHT };
					column3.mask = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
					User32.SendMessage(shellView.LVHandle, BExplorer.Shell.Interop.MSG.LVM_INSERTCOLUMN, 2, ref column3);

					var columnSize = column3.ToCollumns(new PROPERTYKEY() { fmtid = Guid.Parse("B725F130-47EF-101A-A5F1-02608C9EEBAC"), pid = 12 }, typeof(long), false, 90);
					columnSize.ID = "A1";
					shellView.Collumns.Add(columnSize);
				}

				if (!shellView.Collumns.Any(c => c.ID == "A3")) {
					var column4 = new LVCOLUMN() { cx = 100, iSubItem = 3, pszText = "Date Modified", fmt = LVCFMT.LEFT };
					column4.mask = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
					User32.SendMessage(shellView.LVHandle, BExplorer.Shell.Interop.MSG.LVM_INSERTCOLUMN, 3, ref column4);

					var columnDM = column4.ToCollumns(new PROPERTYKEY() { fmtid = Guid.Parse("B725F130-47EF-101A-A5F1-02608C9EEBAC"), pid = 14 }, typeof(DateTime), false, 150);
					columnDM.ID = "A3";
					shellView.Collumns.Add(columnDM);
				}
			}
		}
Пример #12
0
        public void SetColumnSortIcon(ListView listView, int columnIndex, SortOrder order)
        {
            listView.Visible = false;
            IntPtr columnHeader = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int columnNumber = 0; columnNumber <= listView.Columns.Count - 1; columnNumber++)
            {
                IntPtr   columnPtr = new IntPtr(columnNumber);
                LVCOLUMN lvColumn  = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;

                SendMessageLVCOLUMN(columnHeader, HDM_GETITEM, columnPtr, ref lvColumn);

                if (!(order == SortOrder.None) && columnNumber == columnIndex)
                {
                    switch (order)
                    {
                    case System.Windows.Forms.SortOrder.Ascending:
                        lvColumn.fmt &= ~HDF_SORTDOWN;
                        lvColumn.fmt |= HDF_SORTUP;
                        break;

                    case System.Windows.Forms.SortOrder.Descending:
                        lvColumn.fmt &= ~HDF_SORTUP;
                        lvColumn.fmt |= HDF_SORTDOWN;
                        break;
                    }

                    lvColumn.fmt |= (HDF_LEFT | HDF_BITMAP_ON_RIGHT);
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT;
                }

                SendMessageLVCOLUMN(columnHeader, HDM_SETITEM, columnPtr, ref lvColumn);
            }

            listView.Visible = true;
        }
Пример #13
0
        // From: http://social.msdn.microsoft.com/forums/en-US/winforms/thread/e3d5c054-3d74-453c-82fe-53f945545025/
        private static void SetLvmColumnFormat(ListView lv, int index, int fmtSet, int fmtClr)
        {
            if (!lv.IsHandleCreated      ) throw new InvalidOperationException  ( "Bad ListView handle"       );
             if (index >= lv.Columns.Count) throw new ArgumentOutOfRangeException( "Column index out of range" );

             LVCOLUMN lvc = new LVCOLUMN();
             lvc.mask = LVCF_FMT;

             IntPtr buf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVCOLUMN)));
             Marshal.StructureToPtr(lvc, buf, false);
             IntPtr retval = SendMessageW(lv.Handle, LVM_GETCOLUMNW, (IntPtr)index, buf);

             lvc = (LVCOLUMN)Marshal.PtrToStructure(buf, typeof(LVCOLUMN));
             lvc.fmt &= ~fmtClr;
             lvc.fmt |=  fmtSet;
             Marshal.StructureToPtr(lvc, buf, false);

             retval = SendMessageW(lv.Handle, LVM_SETCOLUMNW, (IntPtr)index, buf);

             //Marshal.FreeHGlobal(lvc.pszText);
             Marshal.FreeHGlobal(buf);
        }
Пример #14
0
        /// <summary>
        /// Sets the ListView column header sort icons
        /// </summary>
        public static void SetSortIcon(this ListView list, int columnIndex, SortOrder order)
        {
            var ptr_header = SendMessage(list.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            if (ptr_header != IntPtr.Zero)
            {
                for (var index = 0; index <= list.Columns.Count - 1; index++)
                {
                    var ptr_index = new IntPtr(index);
                    var column    = new LVCOLUMN {
                        mask = HDI_FORMAT
                    };

                    SendMessageLVCOLUMN(ptr_header, HDM_GETITEM, ptr_index, ref column);

                    if (order != SortOrder.None && index == columnIndex)
                    {
                        if (order == SortOrder.Ascending)
                        {
                            column.fmt &= ~HDF_SORTDOWN;
                            column.fmt |= HDF_SORTUP;
                        }
                        else if (order == SortOrder.Descending)
                        {
                            column.fmt &= ~HDF_SORTUP;
                            column.fmt |= HDF_SORTDOWN;
                        }
                        column.fmt |= HDF_LEFT | HDF_BITMAP_ON_RIGHT;
                    }
                    else
                    {
                        column.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT;
                    }

                    SendMessageLVCOLUMN(ptr_header, HDM_SETITEM, ptr_index, ref column);
                }
            }
        }
Пример #15
0
        //This method is used to set arrow icon
        public static void SetSortIcon(this ListView listView, int columnIndex, SortOrder order)
        {
            IntPtr columnHeader = NativeMethods.SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int columnNumber = 0; columnNumber <= listView.Columns.Count - 1; columnNumber++)
            {
                IntPtr   columnPtr = new IntPtr(columnNumber);
                LVCOLUMN lvColumn  = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;

                NativeMethods.SendMessageLVCOLUMN(columnHeader, HDM_GETITEM, columnPtr, ref lvColumn);

                if (!(order == SortOrder.None) && columnNumber == columnIndex)
                {
                    switch (order)
                    {
                    case SortOrder.Ascending:
                        lvColumn.fmt &= ~HDF_SORTDOWN;
                        lvColumn.fmt |= HDF_SORTUP;
                        break;

                    case SortOrder.Descending:
                        lvColumn.fmt &= ~HDF_SORTUP;
                        lvColumn.fmt |= HDF_SORTDOWN;
                        break;
                    }
                    lvColumn.fmt |= (HDF_LEFT | HDF_BITMAP_ON_RIGHT);
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT;
                }

                NativeMethods.SendMessageLVCOLUMN(columnHeader, HDM_SETITEM, columnPtr, ref lvColumn);
            }
        }
Пример #16
0
        public static void AsignarIconoColumna(this ListView listView, int indiceColumna, SortOrder orden)
        {
            IntPtr cabeceraColumna = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int numeroColumna = 0; numeroColumna <= listView.Columns.Count - 1; numeroColumna++)
            {
                IntPtr   punteroColumna  = new IntPtr(numeroColumna);
                LVCOLUMN columnaListView = new LVCOLUMN();
                columnaListView.mask = HDI_FORMAT;

                SendMessageLVCOLUMN(cabeceraColumna, HDM_GETITEM, punteroColumna, ref columnaListView);

                if (!(orden == SortOrder.None) && numeroColumna == indiceColumna)
                {
                    switch (orden)
                    {
                    case System.Windows.Forms.SortOrder.Ascending:
                        columnaListView.fmt &= ~HDF_SORTDOWN;
                        columnaListView.fmt |= HDF_SORTUP;
                        break;

                    case System.Windows.Forms.SortOrder.Descending:
                        columnaListView.fmt &= ~HDF_SORTUP;
                        columnaListView.fmt |= HDF_SORTDOWN;
                        break;
                    }
                    columnaListView.fmt |= (HDF_LEFT | HDF_BITMAP_ON_RIGHT);
                }
                else
                {
                    columnaListView.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT;
                }

                SendMessageLVCOLUMN(cabeceraColumna, HDM_SETITEM, punteroColumna, ref columnaListView);
            }
        }
Пример #17
0
 private static extern IntPtr SendMessageLVColumn(IntPtr hWnd, int msg, int wParam, ref LVCOLUMN lvc);
 private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, ref LVCOLUMN lvc);
Пример #19
0
        private static void SetSortIcon(ListView listView, int columnIndex, SortOrder order)
        {
            IntPtr columnHeader = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int columnNumber = 0; columnNumber <= listView.Columns.Count - 1; columnNumber++)
            {
                IntPtr columnPtr = new IntPtr(columnNumber);
                LVCOLUMN lvColumn = new LVCOLUMN();
                lvColumn.mask = HDI_FORMAT;

                SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref lvColumn);

                if (!(order == SortOrder.None) && columnNumber == columnIndex)
                {
                    switch (order)
                    {
                        case System.Windows.Forms.SortOrder.Ascending:
                            lvColumn.fmt &= ~HDF_SORTDOWN;
                            lvColumn.fmt |= HDF_SORTUP;
                            break;
                        case System.Windows.Forms.SortOrder.Descending:
                            lvColumn.fmt &= ~HDF_SORTUP;
                            lvColumn.fmt |= HDF_SORTDOWN;
                            break;
                    }
                    lvColumn.fmt |= (HDF_LEFT | HDF_BITMAP_ON_RIGHT);
                }
                else
                {
                    lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT;
                }

                SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref lvColumn);
            }
        }
Пример #20
0
		/// <summary>
		/// Convert and Collumns structure to LVCOLUMN (Native Listview Column)
		/// </summary>
		/// <param name="col">the column</param>
		/// <param name="isDetails"></param>
		/// <returns>resulting LVCOLUMN structure</returns>
		public static LVCOLUMN ToNativeColumn(this Collumns col, bool isDetails = false) {
			LVCOLUMN column = new LVCOLUMN();
			column.mask = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_MINWIDTH | LVCF.LVCF_SUBITEM;
			if (isDetails)
				column.cx = col.Width;
			column.pszText = col.Name;
			column.iSubItem = 1;
			column.fmt = col.CollumnType == typeof(long) ? LVCFMT.RIGHT : LVCFMT.LEFT;
			if (isDetails)
				column.cxMin = col.MinWidth;
			return column;
		}
Пример #21
0
        public static void SetSortIcon(ListView listview, int column, SortOrder order)
        {
            if (listview.View != View.Details)
            return;

              IntPtr ColumnHeader = (IntPtr) SendMessage(listview.Handle, (int)LVM_GETHEADER, 0, 0);

              for (int currentColumn = 0; currentColumn <= listview.Columns.Count - 1; currentColumn++)
              {
            IntPtr ColumnPtr = new IntPtr(currentColumn);
            LVCOLUMN lvColumn = new LVCOLUMN();
            lvColumn.mask = (Int32) HDI.FORMAT;
            SendMessage(ColumnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);

            if ((order != System.Windows.Forms.SortOrder.None) && (currentColumn == column))
            {
              switch (order)
              {
            case System.Windows.Forms.SortOrder.Ascending:
              lvColumn.fmt &= ~HDF_SORTDOWN;
              lvColumn.fmt |= HDF_SORTUP;
              break;
            case System.Windows.Forms.SortOrder.Descending:
              lvColumn.fmt &= ~HDF_SORTUP;
              lvColumn.fmt |= HDF_SORTDOWN;
              break;
              }
            }
            else
            {
              lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
            }

            SendMessage(ColumnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
              }
        }
Пример #22
0
 private static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, uint msg, IntPtr wParam, ref LVCOLUMN lParam);
 private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, ref LVCOLUMN lvc);
Пример #24
0
 private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, ref LVCOLUMN lParam);
Пример #25
0
 public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref LVCOLUMN lvc);
 static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref LVCOLUMN lParam);
Пример #27
0
		public static extern int SendMessage(IntPtr hWnd, MSG Msg, int wParam, ref LVCOLUMN lParam);
Пример #28
0
 public static extern IntPtr SendMessage(IntPtr hWnd, uint message, IntPtr wParam, ref LVCOLUMN column);
Пример #29
0
 internal static extern IntPtr SendMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, ref LVCOLUMN lParam);
Пример #30
0
 public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, ref LVCOLUMN lParam);
Пример #31
0
 private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref LVCOLUMN lPLVCOLUMN);
 private void SetDropdown(int column, bool enable)
 {
     LVCOLUMN lvc = new LVCOLUMN();
     lvc.mask = LVCF_FMT;
     lvc.fmt = enable ? LVCFMT_SPLITBUTTON : 0;
     IntPtr res = SendMessage(this.Handle, LVM_SETCOLUMN, (IntPtr)column, ref lvc);
 }
Пример #33
0
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, LVCOLUMN lParam);
Пример #34
0
 public static extern IntPtr SendMessage(IntPtr hWnd, uint message, IntPtr wParam, ref LVCOLUMN column);
Пример #35
0
 public static extern uint SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref LVCOLUMN lParam);
Пример #36
0
 private static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, Int32 Msg, IntPtr wParam, ref LVCOLUMN lPLVCOLUMN);
Пример #37
0
        private void ColumnImageToRight(int index)
        {
            if (!this.IsHandleCreated) return;
            if (Columns.Count == 0) return;
            if (index >= this.Columns.Count) throw new ArgumentOutOfRangeException("Column index out of range");

            IntPtr buf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVCOLUMN)) + 100);
            LVCOLUMN lvc = new LVCOLUMN();
            lvc.mask = 0xffff;
            Marshal.StructureToPtr(lvc, buf, false);
            IntPtr retval = SendMessageW(this.Handle, LVM_GETCOLUMNW, (IntPtr)index, buf);
            lvc = (LVCOLUMN)Marshal.PtrToStructure(buf, typeof(LVCOLUMN));
            lvc.fmt |= 0x1000;
            lvc.pszText = Marshal.StringToHGlobalUni(this.Columns[index].Text);
            Marshal.StructureToPtr(lvc, buf, false);
            retval = SendMessageW(this.Handle, LVM_SETCOLUMNW, (IntPtr)index, buf);
            Marshal.FreeHGlobal(lvc.pszText);
            Marshal.FreeHGlobal(buf);
        }
Пример #38
0
 private static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, Int32 Msg, IntPtr wParam, ref LVCOLUMN lPLVCOLUMN);
Пример #39
0
 public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref LVCOLUMN lvc);