예제 #1
0
 /// <summary>
 /// Initializes a new instance of the SorterBase class with the specified
 /// TableModel, Column index, IComparer and SortOrder
 /// </summary>
 /// <param name="tableModel">The TableModel that contains the data to be sorted</param>
 /// <param name="column">The index of the Column to be sorted</param>
 /// <param name="comparer">The IComparer used to sort the Column's Cells</param>
 /// <param name="sortOrder">Specifies how the Column is to be sorted</param>
 public SorterBase(TableModel tableModel, int column, IComparer comparer, SortOrder sortOrder)
 {
     this.tableModel         = tableModel;
     this.column             = column;
     this.comparer           = comparer;
     this.sortOrder          = sortOrder;
     this.secondarySortOrder = new SortColumnCollection();
     this.secondaryComparers = new IComparerCollection();
 }
예제 #2
0
		/// <summary>
		/// Initializes a new instance of the SorterBase class with the specified 
		/// TableModel, Column index, IComparer and SortOrder
		/// </summary>
		/// <param name="tableModel">The TableModel that contains the data to be sorted</param>
		/// <param name="column">The index of the Column to be sorted</param>
		/// <param name="comparer">The IComparer used to sort the Column's Cells</param>
		/// <param name="sortOrder">Specifies how the Column is to be sorted</param>
		public SorterBase(TableModel tableModel, int column, IComparer comparer, SortOrder sortOrder)
		{
			this.tableModel = tableModel;
			this.column = column;
			this.comparer = comparer;
			this.sortOrder = sortOrder;
            this.secondarySortOrder = new SortColumnCollection();
            this.secondaryComparers = new IComparerCollection();
		}
예제 #3
0
파일: Table.cs 프로젝트: antiduh/XPTable
        /// <summary>
        /// Gets a collection of comparers for the underlying sort order(s)
        /// </summary>
        /// <param name="secondarySortOrders"></param>
        /// <returns></returns>
        private IComparerCollection GetSecondaryComparers(SortColumnCollection secondarySortOrders)
        {
            IComparerCollection comparers = new IComparerCollection();

            foreach (SortColumn sort in secondarySortOrders)
            {
                ComparerBase comparer = null;
                Column column = this.ColumnModel.Columns[sort.SortColumnIndex];

                if (column.Comparer != null)
                {
                    comparer = (ComparerBase) Activator.CreateInstance(column.Comparer, new object[] { this.TableModel, sort.SortColumnIndex, sort.SortOrder });
                }
                else if (column.DefaultComparerType != null)
                {
                    comparer = (ComparerBase) Activator.CreateInstance(column.DefaultComparerType, new object[] { this.TableModel, sort.SortColumnIndex, sort.SortOrder });
                }
                if (comparer != null)
                    comparers.Add(comparer);
            }

            return comparers;
        }
예제 #4
0
        /// <summary>
        /// Initialise default settings
        /// </summary>
        private void Init()
        {
            this.columns = null;

            this.table = null;
            this.headerHeight = ColumnModel.DefaultHeaderHeight;

            this.cellRenderers = new Hashtable();
            this.SetCellRenderer("TEXT", new TextCellRenderer());

            this.cellEditors = new Hashtable();
            this.SetCellEditor("TEXT", new TextCellEditor());

            this.secondarySortOrder = new SortColumnCollection();
        }
예제 #5
0
파일: Demo.cs 프로젝트: adarmus/XPTable
        private void DoSorting(bool withMulti)
        {
            Table table = this.table;       // The Table control on a form - already initialised
            table.Clear();
            table.BeginUpdate();
            table.EnableWordWrap = true;    // If false, then Cell.WordWrap is ignored

            NumberColumn col0 = new NumberColumn("#", 20);
            NumberColumn col1 = new NumberColumn("Height", 50);
            TextColumn col2 = new TextColumn("Name", 80);
            TextColumn col3 = new TextColumn("Surname", 80);
            DateTimeColumn col4 = new DateTimeColumn("Birthday", 120);
            TextColumn col5 = new TextColumn("Comments", 100);

            table.ColumnModel = new ColumnModel(new Column[] { col0, col1, col2, col3, col4, col5 });

            if (withMulti)
            {
                // Surname, Name, Height (descending)
                SortColumnCollection sort = new SortColumnCollection();
                sort.Add(new SortColumn(3, SortOrder.Ascending));   // Surname
                sort.Add(new SortColumn(2, SortOrder.Ascending));   // Name
                sort.Add(new SortColumn(1, SortOrder.Descending));  // Height
                table.ColumnModel.SecondarySortOrders = sort;
            }

            TableModel model = new TableModel();

            AddSortingRow(model, 1, 1.52, "Mark", "Hobbs", "23/1/1978", "likes apples");
            AddSortingRow(model, 2, 1.76, "Dave", "Duke", "2/5/1977", "keeps fish");
            AddSortingRow(model, 3, 1.64, "Holly", "Prench", "14/8/1979", "singer");
            AddSortingRow(model, 4, 1.53, "Mark", "Hobbs", "23/1/1984", "plays football");
            AddSortingRow(model, 5, 1.64, "Dave", "Hobbs", "19/1/1980", "vegetarian");

            this.table.TableModel = model;

            this.table.EndUpdate();
        }
예제 #6
0
        /// <summary>
        /// Initialise default settings
        /// </summary>
        private void Init()
        {
            this.columns = null;

            this.table = null;
            this.headerHeight = ColumnModel.DefaultHeaderHeight;

            this.cellRenderers = new Dictionary<string, ICellRenderer>();
            this.SetCellRenderer(DefaultKey, new TextCellRenderer());

            this.cellEditors = new Dictionary<string, ICellEditor>();
            this.SetCellEditor(DefaultKey, new TextCellEditor());

            this.secondarySortOrder = new SortColumnCollection();
        }