コード例 #1
0
        public bool Regroup()
        {
            try
            {
                NativeMethods.API.ClearListViewGroup(Handle);
                foreach (ThreadedListViewGroup grp in Groups)
                {
                    NativeMethods.API.AddListViewGroup(Handle, grp.GroupText, grp.GroupIndex);
                }

                foreach (var itm in Items)
                {
                    NativeMethods.API.AddItemToGroup(Handle, itm.Index, itm.GroupIndex);
                }

                APIEnableGrouping(true);
                _showInGroups = true;
                _autoGroup    = false;
                _autoGroupCol = null;
                _autoGroupList.Clear();

                return(true);
            }
            catch (Exception ex)
            {
                throw new SystemException("Error in ThreadedListView.Regroup: " + ex.Message);
            }
        }
コード例 #2
0
        public void Remove(string columnID)
        {
            ThreadedListViewColumnHeader c = this[columnID];

            base.Remove(c);
            RaiseThreadedListViewColumnHeaderChangedEvent(
                new ThreadedListViewColumnHeader[] { c },
                ThreadedListViewColumnHeaderChangedAction.Remove);
        }
コード例 #3
0
        public virtual new object Clone()
        {
            ThreadedListViewColumnHeader nh = new ThreadedListViewColumnHeader(this._id, this._colValueType);

            nh.Text      = this.Text;
            nh.Tag       = this.Tag;
            nh.TextAlign = this.TextAlign;
            nh.Width     = this.Width;
            return(nh);
        }
コード例 #4
0
        public int Add(ThreadedListViewColumnHeader colHeader)
        {
            int idx = base.Add(colHeader);

            RaiseThreadedListViewColumnHeaderChangedEvent(
                new ThreadedListViewColumnHeader[] { colHeader },
                ThreadedListViewColumnHeaderChangedAction.Add);

            return(idx);
        }
コード例 #5
0
        public bool AutoGroupByColumn(int columnID)
        {
            if (columnID >= Columns.Count || columnID < 0)
            {
                return(false);
            }

            try
            {
                _autoGroupList.Clear();

                foreach (var itm in Items)
                {
                    if (
                        !_autoGroupList.Contains(itm.SubItems[columnID].Text == String.Empty
                                                     ? _emptyAutoGroupText
                                                     : itm.SubItems[columnID].Text))
                    {
                        _autoGroupList.Add(itm.SubItems[columnID].Text == String.Empty
                                               ? EmptyAutoGroupText
                                               : itm.SubItems[columnID].Text);
                    }
                }

                _autoGroupList.Sort();

                NativeMethods.API.ClearListViewGroup(Handle);
                foreach (var text in _autoGroupList)
                {
                    NativeMethods.API.AddListViewGroup(Handle, text, _autoGroupList.IndexOf(text));
                }

                foreach (var itm in Items)
                {
                    int index =
                        _autoGroupList.IndexOf(itm.SubItems[columnID].Text == ""
                                                   ? _emptyAutoGroupText
                                                   : itm.SubItems[columnID].Text);
                    NativeMethods.API.AddItemToGroup(Handle, itm.Index, index);
                }

                APIEnableGrouping(true);
                _showInGroups = true;
                _autoGroup    = true;
                _autoGroupCol = Columns[columnID];

                Refresh();

                return(true);
            }
            catch (Exception ex)
            {
                throw new SystemException("Error in ThreadedListView.AutoGroupByColumn: " + ex.Message);
            }
        }
コード例 #6
0
 /// <summary>
 /// Returns the index of the Column identified by column ID.
 /// </summary>
 /// <param name="columnID">string</param>
 /// <returns>int. -1, if not found</returns>
 public int GetIndexByKey(string columnID)
 {
     for (int i = 0; i < base.Count; i++)
     {
         ThreadedListViewColumnHeader c = this[i];
         if (c.Key == columnID)
         {
             return(i);
         }
     }
     return(-1);
 }
コード例 #7
0
        /// <summary>
        /// Returns a collection for faster column key to index lookup.
        /// Can be used to create new items/subitems according to the current column keys.
        /// </summary>
        public ColumnKeyIndexMap GetColumnIndexMap()
        {
            ColumnKeyIndexMap map = new ColumnKeyIndexMap(base.Count);

            lock (this) {
                for (int i = 0; i < base.Count; i++)
                {
                    ThreadedListViewColumnHeader c = this[i];
                    map.Add(c.Key, i);
                }
            }
            return(map);
        }
コード例 #8
0
        public ThreadedListViewColumnHeader Add(string id, string caption, Type valueType, int width, HorizontalAlignment textAlign)
        {
            ThreadedListViewColumnHeader c = new ThreadedListViewColumnHeader(id, valueType);

            c.Text      = caption;
            c.Width     = width;
            c.TextAlign = textAlign;
            int index = base.Add(c);

            RaiseThreadedListViewColumnHeaderChangedEvent(
                new ThreadedListViewColumnHeader[] { c },
                ThreadedListViewColumnHeaderChangedAction.Add);

            return(c);
        }