コード例 #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="InternalItem"/> class.
            /// </summary>
            /// <param name="userItem">The user item.</param>
            /// <param name="owner">The owner.</param>
            public InternalItem([NotNull] IGroupedListViewItem userItem,
                                [NotNull] GroupedListView owner)
            {
                Assert.ArgumentNotNull(owner, nameof(owner));
                Assert.ArgumentNotNull(userItem, nameof(userItem));
                Assert.NotNullOrEmpty(userItem.Name,
                                      "userItem.Name must not be null nor empty");

                _owner    = owner;
                _userItem = userItem;

                _checkBox.Text     = string.Empty;
                _checkBox.AutoSize = true;
                _checkBox.Tag      = this;

                _pictureBox.Size     = new Size(1, 1);             // very small
                _pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
                _pictureBox.Tag      = this;

                _labelName.AutoSize = true;
                _labelName.Tag      = this;

                _labelInfo.AutoSize = true;
                _labelInfo.Tag      = this;

                RefreshControls();
            }
コード例 #2
0
        public void AddItem([NotNull] IGroupedListViewItem item)
        {
            Assert.ArgumentNotNull(item, nameof(item));

            _itemList.Add(new InternalItem(item, this));
            ListChanged();
        }
コード例 #3
0
        private void RebuildTable()
        {
            Stopwatch stopwatch1 = null;

            if (_msg.IsVerboseDebugEnabled)
            {
                stopwatch1 = _msg.DebugStartTiming();
            }

            CreateTableLayoutPanel();

            _msg.DebugStopTiming(stopwatch1, "GroupedListView: CreateTableLayoutPanel");

            Stopwatch stopwatch2 = null;

            if (_msg.IsVerboseDebugEnabled)
            {
                stopwatch2 = _msg.DebugStartTiming();
            }

            _tableLayoutPanel.SuspendLayout();

            _tableLayoutPanel.RowCount    = 0;          // grow as needed
            _tableLayoutPanel.ColumnCount = _showCheckBoxes
                                                                ? 4
                                                                : 3;

            _itemList.Sort();               // by Group, then by Name
            _groupNameToControlMap.Clear(); // reset

            var    rowNumber      = 0;
            string currentHeading = null;

            foreach (InternalItem item in _itemList)
            {
                IGroupedListViewItem userItem = item.UserItem;

                string headingText = userItem.Group ?? NullGroupHeadingText;

                if (string.CompareOrdinal(headingText, currentHeading) != 0)
                {
                    currentHeading = headingText;
                    AddGroupHeading(currentHeading, rowNumber++);
                }

                AddItemEntry(item, rowNumber++);
            }

            AddFillerRow(rowNumber);

            _tableLayoutPanel.ResumeLayout();

            _msg.DebugStopTiming(stopwatch2, "GroupedListView: rebuilt table layout");
        }