示例#1
0
        /// <summary>
        /// Sets the image of the sorted ColumnHeader.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="sortorder"></param>
        protected void SetImage(int column, Yaowi.Common.Collections.SortOrder sortorder)
        {
            // Nothing to do
            if (this.listview.SmallImageList == null)
            {
                return;
            }

            string key = String.Empty;

            foreach (ColumnHeader ch in this.ListView.Columns)
            {
                ch.ImageKey = null;
            }

            if (sortorder == Yaowi.Common.Collections.SortOrder.Ascending)
            {
                key = imagekeyup;
            }
            else
            {
                key = imagekeydown;
            }

            if (key != null && this.listview.SmallImageList.Images.ContainsKey(key))
            {
                this.ListView.Columns[column].ImageKey = key;
            }
        }
示例#2
0
        /// <summary>
        /// Sorts the ListView by the specified column.
        /// </summary>
        /// <param name="column"></param>
        protected void Sort(int column)
        {
            // Toggle ASC and DESC
            if (column == lastsortcolumn)
            {
                if (sortorder == Yaowi.Common.Collections.SortOrder.Ascending)
                {
                    sortorder = Yaowi.Common.Collections.SortOrder.Descending;
                }
                else
                {
                    sortorder = Yaowi.Common.Collections.SortOrder.Ascending;
                }
            }
            else
            {
                sortorder = Yaowi.Common.Collections.SortOrder.Ascending;
            }

            lastsortcolumn = column;

            // Get the columns comparer (if the column ist registered use the StringComparer by default)
            ISortComparer c = null;

            if (comparercollection.ContainsKey(this.ListView.Columns[column].Text))
            {
                c = comparercollection[this.ListView.Columns[column].Text];
            }
            else
            {
                c = new Yaowi.Common.Collections.StringComparer();
            }

            // Initialize the ListViewItemComparer
            ListViewItemComparer lvc = new ListViewItemComparer(column, c);

            lvc.SortOrder = sortorder;
            this.ListView.ListViewItemSorter = lvc;

            // Sort!
            this.ListView.Sort();

            // Set ColumnHeaders image
            SetImage(column, sortorder);
        }
示例#3
0
        /// <summary>
        /// Sorts the ListView by the specified column.
        /// </summary>
        /// <param name="column"></param>
        protected void Sort(int column)
        {
            // Toggle ASC and DESC
              if (column == lastsortcolumn)
              {
            if (sortorder == Yaowi.Common.Collections.SortOrder.Ascending)
              sortorder = Yaowi.Common.Collections.SortOrder.Descending;
            else
              sortorder = Yaowi.Common.Collections.SortOrder.Ascending;
              }
              else
              {
            sortorder = Yaowi.Common.Collections.SortOrder.Ascending;
              }

              lastsortcolumn = column;

              // Get the columns comparer (if the column ist registered use the StringComparer by default)
              ISortComparer c = null;
              if (comparercollection.ContainsKey(this.ListView.Columns[column].Text))
            c = comparercollection[this.ListView.Columns[column].Text];
              else
            c = new Yaowi.Common.Collections.StringComparer();

              // Initialize the ListViewItemComparer
              ListViewItemComparer lvc = new ListViewItemComparer(column, c);
              lvc.SortOrder = sortorder;
              this.ListView.ListViewItemSorter = lvc;

              // Sort!
              this.ListView.Sort();

              // Set ColumnHeaders image
              SetImage(column, sortorder);
        }