Example #1
0
		/// <summary> Sets the sort arrow to a particular column in the list view. </summary>
		/// <param name="ColumnToShowArrow"> Index of the column where the sort arrow will be displayed </param>
		public void SetSortArrow( int ColumnToShowArrow, bool bSortModeAscending )
		{
			if( ListViewHeader == null )
			{
				return;
			}

			IntPtr ColumnHeader = ListViewHeader.Handle;

			for( int ColumnIndex = 0; ColumnIndex < Columns.Count; ColumnIndex++ )
			{
				IntPtr ColumnPtr = new IntPtr( ColumnIndex );
				Win32.HDITEM ListViewColumn = new Win32.HDITEM();
				ListViewColumn.mask = Win32.HDI_FORMAT;
				Win32.SendMessageHeaderItem( ColumnHeader, Win32.HDM_GETITEM, ColumnPtr, ref ListViewColumn );

				bool bIsSortArrowDown = ( ( ListViewColumn.fmt & Win32.HDF_SORTDOWN ) == Win32.HDF_SORTDOWN );
				bool bIsSortArrowUp = ( ( ListViewColumn.fmt & Win32.HDF_SORTUP ) == Win32.HDF_SORTUP );

				// Change the sort arrow to opposite direction.
				if( ColumnToShowArrow == ColumnIndex )
				{
					if( bSortModeAscending )
					{
						ListViewColumn.fmt &= ~Win32.HDF_SORTDOWN;
						ListViewColumn.fmt |= Win32.HDF_SORTUP;
					}
					else
					{
						ListViewColumn.fmt &= ~Win32.HDF_SORTUP;
						ListViewColumn.fmt |= Win32.HDF_SORTDOWN;
					}
				}
				else
				{
					ListViewColumn.fmt &= ~Win32.HDF_SORTDOWN & ~Win32.HDF_SORTUP;
				}

				Win32.SendMessageHeaderItem( ColumnHeader, Win32.HDM_SETITEM, ColumnPtr, ref ListViewColumn );
			}
		}
Example #2
0
        /// <summary> Sets the sort arrow to a particular column in the list view. </summary>
        /// <param name="ColumnToShowArrow"> Index of the column where the sort arrow will be displayed </param>
        public void SetSortArrow(int ColumnToShowArrow, bool bSortModeAscending)
        {
            if (ListViewHeader == null)
            {
                return;
            }

            IntPtr ColumnHeader = ListViewHeader.Handle;

            for (int ColumnIndex = 0; ColumnIndex < Columns.Count; ColumnIndex++)
            {
                IntPtr       ColumnPtr      = new IntPtr(ColumnIndex);
                Win32.HDITEM ListViewColumn = new Win32.HDITEM();
                ListViewColumn.mask = Win32.HDI_FORMAT;
                Win32.SendMessageHeaderItem(ColumnHeader, Win32.HDM_GETITEM, ColumnPtr, ref ListViewColumn);

                bool bIsSortArrowDown = ((ListViewColumn.fmt & Win32.HDF_SORTDOWN) == Win32.HDF_SORTDOWN);
                bool bIsSortArrowUp   = ((ListViewColumn.fmt & Win32.HDF_SORTUP) == Win32.HDF_SORTUP);

                // Change the sort arrow to opposite direction.
                if (ColumnToShowArrow == ColumnIndex)
                {
                    if (bSortModeAscending)
                    {
                        ListViewColumn.fmt &= ~Win32.HDF_SORTDOWN;
                        ListViewColumn.fmt |= Win32.HDF_SORTUP;
                    }
                    else
                    {
                        ListViewColumn.fmt &= ~Win32.HDF_SORTUP;
                        ListViewColumn.fmt |= Win32.HDF_SORTDOWN;
                    }
                }
                else
                {
                    ListViewColumn.fmt &= ~Win32.HDF_SORTDOWN & ~Win32.HDF_SORTUP;
                }

                Win32.SendMessageHeaderItem(ColumnHeader, Win32.HDM_SETITEM, ColumnPtr, ref ListViewColumn);
            }
        }