Esempio n. 1
0
        public bool Regroup()
        {
            try
            {
                ListViewAPI.ClearListViewGroup(this);
                foreach (XPListViewGroup grp in this.Groups)
                {
                    ListViewAPI.AddListViewGroup(this, grp.GroupText, grp.GroupIndex);
                }

                foreach (XPListViewItem itm in this.Items)
                {
                    ListViewAPI.AddItemToGroup(this, itm.Index, itm.GroupIndex);
                }

                int param = 0;
                ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_ENABLEGROUPVIEW, 1, ref param);
                _showInGroups = true;
                _autoGroup    = false;
                _autoGroupCol = null;
                _autoGroupList.Clear();

                return(true);
            }
            catch (Exception ex)
            {
                throw new SystemException("Error in XPListView.Regroup: " + ex.Message);
            }
        }
Esempio n. 2
0
        public bool AutoGroupByColumn(int columnID)
        {
            if (columnID >= this.Columns.Count || columnID < 0)
            {
                return(false);
            }

            try
            {
                _autoGroupList.Clear();
                foreach (XPListViewItem itm in this.Items)
                {
                    if (
                        !_autoGroupList.Contains(itm.SubItems[columnID].Text == ""
                                       ? _emptyAutoGroupText
                                       : itm.SubItems[columnID].Text))
                    {
                        _autoGroupList.Add(itm.SubItems[columnID].Text == "" ? EmptyAutoGroupText : itm.SubItems[columnID].Text);
                    }
                }

                _autoGroupList.Sort();

                ListViewAPI.ClearListViewGroup(this);
                foreach (string text in _autoGroupList)
                {
                    ListViewAPI.AddListViewGroup(this, text, _autoGroupList.IndexOf(text));
                }

                foreach (XPListViewItem itm in this.Items)
                {
                    ListViewAPI.AddItemToGroup(this, itm.Index,
                                               _autoGroupList.IndexOf(itm.SubItems[columnID].Text == ""
                                                              ? _emptyAutoGroupText
                                                              : itm.SubItems[columnID].Text));
                }

                int param = 0;
                ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_ENABLEGROUPVIEW, 1, ref param);
                _showInGroups = true;
                _autoGroup    = true;
                _autoGroupCol = this.Columns[columnID];

                this.Refresh();

                return(true);
            }
            catch (Exception ex)
            {
                throw new SystemException("Error in XPListView.AutoGroupByColumn: " + ex.Message);
            }
        }
 public new void Clear()
 {
     ListViewAPI.ClearListViewGroup(_owner);
     List.Clear();
 }