/// <summary>Initializes a new instance of the <see cref="VisualListViewItem" /> class.</summary> /// <param name="subItems"> /// The collection 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(VisualListViewSubItemCollection subItems, int imageIndex) : this() { _subItemCollection[0].ImageIndex = imageIndex; foreach (VisualListViewSubItem subItem in subItems) { subItem.Owner = this; _subItemCollection.Add(subItem); } }
/// <summary>Initializes a new instance of the <see cref="VisualListViewItem" /> class.</summary> /// <param name="listView">The list View.</param> public VisualListViewItem(VisualListView listView) : this() { _subItemCollection = new VisualListViewSubItemCollection(listView) { ListView = listView }; _listView = listView; _subItemCollection.ListView = _listView; _subItemCollection.ChangedEvent += SubItemCollection_Changed; }
/// <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); }
/// <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); }
/// <summary>Initializes a new instance of the <see cref="VisualListViewItem" /> class.</summary> public VisualListViewItem() { _selected = false; _tag = null; _foreColor = Color.Black; _rowBorderColor = Color.Black; _rowBorderSize = 0; _backColor = Color.White; _font = SystemFonts.DefaultFont; _imageList = new ImageList(); _lastIndex = -1; if (_listView != null) { _subItemCollection = new VisualListViewSubItemCollection(_listView); } else { _subItemCollection = new VisualListViewSubItemCollection(); } _subItemCollection.ChangedEvent += SubItemCollection_Changed; }