示例#1
0
        protected override void OnColumnClick(ColumnClickEventArgs e)
        {
            if (!DesignMode && View == View.Details && !VirtualMode)
            {
                ColumnHeader column = Columns[e.Column];

                SmartColumn sc = column as SmartColumn;
                if (sc != null && sc.Sortable)
                {
                    bool extend = (Control.ModifierKeys & Keys.Control) != 0;

                    if (!extend)
                    {
                        if (SortColumns.Count == 1 && SortColumns[0] == sc)
                        {
                            sc.ReverseSort = !sc.ReverseSort;
                        }
                        else
                        {
                            SortColumns.Clear();
                            SortColumns.Add(sc);
                            sc.ReverseSort = false;
                        }
                    }
                    else
                    {
                        if (SortColumns.Contains(sc))
                        {
                            sc.ReverseSort = !sc.ReverseSort;
                        }
                        else
                        {
                            sc.ReverseSort = false;
                            SortColumns.Add(sc);
                        }
                    }
                    Sort();
                    UpdateSortGlyphs();
                }
            }
            base.OnColumnClick(e);
        }
示例#2
0
        internal void UpdateSortGlyphs()
        {
            if (!IsHandleCreated || !SupportsSortGlypgs || DesignMode || View != View.Details)
            {
                return;
            }

            foreach (ColumnHeader ch in Columns)
            {
                SmartColumn sc = ch as SmartColumn;

                if (sc != null)
                {
                    if (SortColumns.Contains(sc))
                    {
                        SetSortIcon(sc.Index, sc.ReverseSort ? SortIcon.Descending : SortIcon.Ascending);
                    }
                    else
                    {
                        SetSortIcon(sc.Index, SortIcon.None);
                    }
                }
            }
        }
        public void SetValue(int column, string value)
        {
            if (column < 0)
            {
                throw new ArgumentOutOfRangeException("column");
            }
            // Allow null values!

            bool checkGroup = false;
            int  c          = -1;

            if (ListView.AllColumns.Count > 0)
            {
                if (column >= ListView.AllColumns.Count)
                {
                    throw new ArgumentOutOfRangeException("column");
                }

                checkGroup = true;
                SmartColumn sc = ListView.AllColumns[column];

                if (sc.Index >= 0)
                {
                    c = sc.Index;
                }
            }
            else
            {
                if (column >= ListView.Columns.Count)
                {
                    throw new ArgumentOutOfRangeException("column");
                }

                c = column;
            }

            if (c >= 0)
            {
                while (c >= SubItems.Count)
                {
                    SubItems.Add("");
                }

                SubItems[c].Text = value;
            }

            if (_values == null || _values.Length < column)
            {
                string[] values = new string[column + 1];

                if (_values != null)
                {
                    _values.CopyTo(values, 0);
                }

                _values = values;
            }

            _values[column] = value;

            if (checkGroup && ListView.GroupColumns.Contains(ListView.AllColumns[column]))
            {
                UpdateGroup();
            }
        }