Exemple #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);
            }
        }
Exemple #2
0
 public void AddRange(XPListViewItem[] values)
 {
     base.AddRange(values);
     foreach (XPListViewItem itm in values)
     {
         ListViewAPI.AddItemToGroup(((XPListView)itm.ListView), itm.Index, itm.GroupIndex);
         if (ItemAdded != null)
         {
             ItemAdded(this, new ListViewItemEventArgs(itm));
         }
     }
 }
Exemple #3
0
        public XPListViewItem Add(XPListViewItem item)
        {
            XPListViewItem itm;

            itm = ((XPListViewItem)base.Add(item));
            ListViewAPI.AddItemToGroup(((XPListView)itm.ListView), itm.Index, itm.GroupIndex);
            if (ItemAdded != null)
            {
                ItemAdded(this, new ListViewItemEventArgs(itm));
            }
            return(itm);
        }
Exemple #4
0
        private void _items_ItemAdded(object sender, ListViewItemEventArgs e)
        {
            string text;

            if (_autoGroup)
            {
                text = e.Item.SubItems[_autoGroupCol.Index].Text;
                if (!_autoGroupList.Contains(text))
                {
                    _autoGroupList.Add(text);
                    ListViewAPI.AddListViewGroup(this, text, _autoGroupList.IndexOf(text));
                }
                ListViewAPI.AddItemToGroup(this, e.Item.Index, _autoGroupList.IndexOf(text));
            }
        }
Exemple #5
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);
            }
        }