コード例 #1
0
 protected override void OnColumnClick(System.Windows.Forms.ColumnClickEventArgs e)
 {
     base.OnColumnClick(e);
     this.SuspendLayout();
     if (_showInGroups)
     {
         int param = 0;
         ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_ENABLEGROUPVIEW, 0, ref param);
     }
     this.ListViewItemSorter = new XPListViewItemComparer(e.Column);
     if (this.Sorting == SortOrder.Descending)
     {
         this.Sorting = SortOrder.Ascending;
     }
     else
     {
         this.Sorting = SortOrder.Descending;
     }
     this.Sort();
     if (_showInGroups)
     {
         int param = 0;
         ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_ENABLEGROUPVIEW, 1, ref param);
         if (_autoGroup == true)
         {
             AutoGroupByColumn(_autoGroupCol.Index);
         }
         else
         {
             Regroup();
         }
     }
     this.ResumeLayout();
 }
コード例 #2
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);
            }
        }
コード例 #3
0
        public void SetTileHeight(int height)
        {
            ListViewAPI.LVTILEVIEWINFO apiTileView;

            this.SuspendLayout();

            int param = 0;

            _apiRetVal = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_GETVIEW, ListViewAPI.LV_VIEW_TILE, ref param);
            if ((int)_apiRetVal != ListViewAPI.LV_VIEW_TILE)
            {
                return;
            }


            apiTileView = new ListViewAPI.LVTILEVIEWINFO();

            apiTileView.cbSize      = Marshal.SizeOf(typeof(ListViewAPI.LVTILEVIEWINFO));
            apiTileView.dwMask      = ListViewAPI.LVTVIM_TILESIZE | ListViewAPI.LVTVIM_LABELMARGIN;
            _apiRetVal              = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_GETTILEVIEWINFO, 0, ref apiTileView);
            apiTileView.dwFlags     = ListViewAPI.LVTVIF_FIXEDHEIGHT;
            apiTileView.sizeTile.cy = height;
            _apiRetVal              = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_SETTILEVIEWINFO, 0, ref apiTileView);


            this.ResumeLayout();
        }
コード例 #4
0
        public void SetTileSize(Size size)
        {
            ListViewAPI.LVTILEVIEWINFO apiTileView;
            ListViewAPI.INTEROP_SIZE   apiSize;

            this.SuspendLayout();

            int param = 0;

            _apiRetVal = ListViewAPI.SendMessage((System.IntPtr) this.Handle, ListViewAPI.LVM_GETVIEW, ListViewAPI.LV_VIEW_TILE, ref param);
            if ((int)_apiRetVal != ListViewAPI.LV_VIEW_TILE)
            {
                return;
            }

            apiSize    = new ListViewAPI.INTEROP_SIZE();
            apiSize.cx = size.Width;
            apiSize.cy = size.Height;

            apiTileView          = new ListViewAPI.LVTILEVIEWINFO();
            apiTileView.cbSize   = Marshal.SizeOf(typeof(ListViewAPI.LVTILEVIEWINFO));
            apiTileView.dwMask   = ListViewAPI.LVTVIM_TILESIZE | ListViewAPI.LVTVIM_LABELMARGIN;
            _apiRetVal           = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_GETTILEVIEWINFO, 0, ref apiTileView);
            apiTileView.dwFlags  = ListViewAPI.LVTVIF_FIXEDSIZE;
            apiTileView.sizeTile = apiSize;
            _apiRetVal           = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_SETTILEVIEWINFO, 0, ref apiTileView);

            this.ResumeLayout();
        }
コード例 #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);
            }
        }
コード例 #6
0
        public void ShowTiles(int[] columns)
        {
            ListViewAPI.LVTILEVIEWINFO apiTileView;
            ListViewAPI.LVTILEINFO     apiTile;

            IntPtr lpcol = Marshal.AllocHGlobal(columns.Length * 4);

            Marshal.Copy(columns, 0, lpcol, columns.Length);

            int param = 0;

            _apiRetVal = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_SETVIEW, ListViewAPI.LV_VIEW_TILE, ref param);

            apiTileView         = new ListViewAPI.LVTILEVIEWINFO();
            apiTileView.cbSize  = Marshal.SizeOf(typeof(ListViewAPI.LVTILEVIEWINFO));
            apiTileView.dwMask  = ListViewAPI.LVTVIM_COLUMNS | ListViewAPI.LVTVIM_TILESIZE;
            apiTileView.dwFlags = ListViewAPI.LVTVIF_AUTOSIZE;
            apiTileView.cLines  = columns.Length;


            _apiRetVal = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_SETTILEVIEWINFO, 0, ref apiTileView);

            foreach (XPListViewItem itm in this.Items)
            {
                apiTile           = new ListViewAPI.LVTILEINFO();
                apiTile.cbSize    = Marshal.SizeOf(typeof(ListViewAPI.LVTILEINFO));
                apiTile.iItem     = itm.Index;
                apiTile.cColumns  = columns.Length;
                apiTile.puColumns = (int)lpcol;

                _apiRetVal = ListViewAPI.SendMessage(this.Handle, ListViewAPI.LVM_SETTILEINFO, 0, ref apiTile);
            }

            //columns = null;
            Marshal.FreeHGlobal(lpcol);
        }