コード例 #1
0
        /// <summary>Initializes a new instance of the <see cref="VisualListViewItem" /> class.</summary>
        /// <param name="subItems">The array of type <see cref="VisualListViewSubItem" /> that represents the subitems of the item.</param>
        /// <param name="imageIndex">
        ///     The zero-based index of the image within the <see cref="ImageList" /> associated with the
        ///     <see cref="VisualListViewAdvanced" /> that contains the item.
        /// </param>
        public VisualListViewItem(VisualListViewSubItem[] subItems, int imageIndex) : this()
        {
            _subItemCollection[0].ImageIndex = imageIndex;

            foreach (VisualListViewSubItem subItem in subItems)
            {
                subItem.Owner = this;
                _subItemCollection.Add(subItem);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Creates an identical copy of the current <see cref="VisualListViewItem" /> that is not attached to any list
        ///     view control.
        /// </summary>
        /// <returns>The <see cref="Object" />.</returns>
        public virtual object Clone()
        {
            VisualListViewSubItemCollection _clonedSubItemCollection = new VisualListViewSubItemCollection();

            for (var i = 0; i < _subItemCollection.Count; i++)
            {
                VisualListViewSubItem _subItem = _subItemCollection[i];

                _clonedSubItemCollection.Add(new VisualListViewSubItem(null, _subItem.Text, _subItem.ForeColor, _subItem.BackColor, _subItem.Font)
                {
                    Tag = _subItem.Tag
                });
            }

            Type _clonedType = GetType();
            VisualListViewItem _listViewItem;

            if (_clonedType == typeof(VisualListViewItem))
            {
                _listViewItem = new VisualListViewItem(_clonedSubItemCollection, _subItemCollection[0].ImageIndex);
            }
            else
            {
                _listViewItem = (VisualListViewItem)Activator.CreateInstance(_clonedType);
            }

            _listViewItem = new VisualListViewItem(_clonedSubItemCollection, -1)
            {
                ImageIndex = _subItemCollection[0].ImageIndex,
                Tag        = _tag,
                BackColor  = _backColor,
                ForeColor  = _foreColor,
                Font       = _font,
                Text       = Text
            };

            // if (!string.IsNullOrEmpty(_imageKey))
            // {
            // _listViewItem.ImageIndexer.Key = _imageKey;
            // }
            return(_listViewItem);
        }
コード例 #3
0
        /// <summary>
        ///     Creates an identical copy of the current <see cref="VisualListViewItem" /> that is not attached to any list
        ///     view control.
        /// </summary>
        /// <returns>The <see cref="Object" />.</returns>
        public virtual object Clone()
        {
            VisualListViewSubItemCollection _clonedSubItemCollection = new VisualListViewSubItemCollection();

            for (var i = 0; i < _subItemCollection.Count; i++)
            {
                VisualListViewSubItem _subItem = _subItemCollection[i];

                _clonedSubItemCollection.Add(new VisualListViewSubItem(null, _subItem.Text, _subItem.ForeColor, _subItem.BackColor, _subItem.Font)
                {
                    Tag = _subItem.Tag
                });
            }

            Type _clonedType = GetType();
            VisualListViewItem _listViewItem;

            if (_clonedType == typeof(VisualListViewItem))
            {
                _listViewItem = new VisualListViewItem(_clonedSubItemCollection, _subItemCollection[0].ImageIndex);
            }
            else
            {
                _listViewItem = (VisualListViewItem)Activator.CreateInstance(_clonedType);
            }

            _listViewItem.SubItems.Clear();
            foreach (VisualListViewSubItem subItem in _clonedSubItemCollection)
            {
                _listViewItem.SubItems.Add(subItem);
            }

            _listViewItem.Checked    = _subItemCollection[0].Checked;
            _listViewItem.ImageIndex = _subItemCollection[0].ImageIndex;
            _listViewItem.Tag        = _tag;
            _listViewItem.BackColor  = _backColor;
            _listViewItem.ForeColor  = _foreColor;
            _listViewItem.Font       = _font;
            _listViewItem.Text       = Text;
            return(_listViewItem);
        }