示例#1
0
 public int FindIndex(TableColumn column)
 {
     return items.FindIndex(x => x == column);
 }
示例#2
0
        public void Remove(TableColumn column)
        {
            if (column.control != null)
                column.control.Dispose();
            items.Remove(column);

            owner.UpdateColumns();
        }
示例#3
0
 public void Add(TableColumn column)
 {
     items.Add(column);
 }
示例#4
0
        public void Add(string columnName, string headerText)
        {
            TableColumn column = new TableColumn(this);
            column.Name = columnName;
            column.HeaderText = headerText;
            Add(column);

            owner.UpdateColumn(column);
        }
示例#5
0
        public virtual void Sort(TableColumn column, ListSortDirection direction)
        {
            if (column == null) return;

            int columnIndex = Columns.FindIndex(column);
            Dictionary<TableRow, object[]> items = new Dictionary<TableRow, object[]>();
            for (int i = 0; i < Rows.Count; i++)
            {
                var r = Rows[i];
                items.Add(r, r.Items);
            }

            var itemsList = items.ToList();
            if (direction == ListSortDirection.Ascending)
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                        return 0;

                    if (v1 == null)
                        return -1;
                    if (v2 == null)
                        return 1;

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return we;
                });
            else
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                        return 0;

                    if (v1 == null)
                        return 1;
                    if (v2 == null)
                        return -1;

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return -we;
                });

            Rows.ClearList();

            for (int i = 0; i < itemsList.Count; i++)
                Rows.Add(itemsList[i].Key);

            AlignRows();

            if (lastSortedColumn != null)
                lastSortedColumn.control.Padding = new Padding(8, 0, 8, 0);
            lastSortedColumn = column;
            lastSortedColumn.control.Padding = new Padding(24, 0, 8, 0);
        }
示例#6
0
        internal void UpdateColumn(TableColumn column)
        {
            CreateTopLeftButton();

            if (column.control == null)
            {
                var cButton = new TableColumnButton(this, ColumnsStyle);
                cButton.column = column;
                cButton.EnableHorizontalResizing = true;
                cButton.Name = column.Name;
                cButton.table = this;
                cButton.Text = column.HeaderText;

                column.control = cButton;
                Controls.Add(cButton);
            }

            column.control.Visible = !columnHeadersHidden;
        }
示例#7
0
        public virtual void Sort(TableColumn column, ListSortDirection direction)
        {
            if (column == null)
            {
                return;
            }

            int columnIndex = Columns.FindIndex(column);
            Dictionary <TableRow, object[]> items = new Dictionary <TableRow, object[]>();

            for (int i = 0; i < Rows.Count; i++)
            {
                var r = Rows[i];
                items.Add(r, r.Items);
            }

            var itemsList = items.ToList();

            if (direction == ListSortDirection.Ascending)
            {
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                    {
                        return(0);
                    }

                    if (v1 == null)
                    {
                        return(-1);
                    }
                    if (v2 == null)
                    {
                        return(1);
                    }

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return(we);
                });
            }
            else
            {
                itemsList.Sort((x, y) =>
                {
                    var v1 = x.Value[columnIndex];
                    var v2 = y.Value[columnIndex];

                    if (v1 == null && v2 == null)
                    {
                        return(0);
                    }

                    if (v1 == null)
                    {
                        return(1);
                    }
                    if (v2 == null)
                    {
                        return(-1);
                    }

                    var we = v1.ToString().CompareTo(v2.ToString());
                    return(-we);
                });
            }

            Rows.ClearList();

            for (int i = 0; i < itemsList.Count; i++)
            {
                Rows.Add(itemsList[i].Key);
            }

            AlignRows();

            if (lastSortedColumn != null)
            {
                lastSortedColumn.control.Padding = new Padding(8, 0, 8, 0);
            }
            lastSortedColumn = column;
            lastSortedColumn.control.Padding = new Padding(24, 0, 8, 0);
        }
示例#8
0
 public int FindIndex(TableColumn column)
 {
     return(items.FindIndex(x => x == column));
 }
示例#9
0
 public void Add(TableColumn column)
 {
     items.Add(column);
 }