1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
23 // Ravindra (rkumar@novell.com)
24 // Mike Kestner <mkestner@novell.com>
25 // Daniel Nauck (dna(at)mono-project(dot)de)
27 using System.Collections;
28 using System.ComponentModel;
30 using System.Runtime.Serialization;
32 namespace System.Windows.Forms
34 [DefaultProperty ("Text")]
35 [DesignTimeVisible (false)]
38 [TypeConverter (typeof (ListViewItemConverter))]
39 public class ListViewItem : ICloneable, ISerializable
41 #region Instance Variables
42 private int image_index = -1;
43 private bool is_checked = false;
44 private bool is_focused = false;
45 private int state_image_index = -1;
46 private ListViewSubItemCollection sub_items;
48 private bool use_item_style = true;
50 private ListViewGroup group = null;
51 private string name = String.Empty;
52 private string image_key = String.Empty;
55 Rectangle checkbox_rect; // calculated by CalcListViewItem method
66 #endregion Instance Variables
68 #region Public Constructors
69 public ListViewItem ()
71 this.sub_items = new ListViewSubItemCollection (this);
72 this.sub_items.Add ("");
75 public ListViewItem (string text) : this (text, -1)
79 public ListViewItem (string [] items) : this (items, -1)
83 public ListViewItem (ListViewItem.ListViewSubItem [] subItems, int imageIndex)
85 this.sub_items = new ListViewSubItemCollection (this);
86 this.sub_items.AddRange (subItems);
87 this.image_index = imageIndex;
90 public ListViewItem (string text, int imageIndex)
92 this.image_index = imageIndex;
93 this.sub_items = new ListViewSubItemCollection (this);
94 this.sub_items.Add (text);
97 public ListViewItem (string [] items, int imageIndex)
99 this.sub_items = new ListViewSubItemCollection (this);
100 this.sub_items.AddRange (items);
101 this.image_index = imageIndex;
104 public ListViewItem (string [] items, int imageIndex, Color foreColor,
105 Color backColor, Font font)
107 this.sub_items = new ListViewSubItemCollection (this);
108 this.sub_items.AddRange (items);
109 this.image_index = imageIndex;
110 ForeColor = foreColor;
111 BackColor = backColor;
116 public ListViewItem(string[] items, string imageKey) : this(items)
118 this.ImageKey = imageKey;
121 public ListViewItem(string text, string imageKey) : this(text)
123 this.ImageKey = imageKey;
126 public ListViewItem(ListViewSubItem[] subItems, string imageKey) : this()
128 this.sub_items.AddRange(subItems);
129 this.ImageKey = imageKey;
132 public ListViewItem(string[] items, string imageKey, Color foreColor,
133 Color backColor, Font font) : this()
135 this.sub_items = new ListViewSubItemCollection(this);
136 this.sub_items.AddRange(items);
137 ForeColor = foreColor;
138 BackColor = backColor;
140 this.ImageKey = imageKey;
143 public ListViewItem(ListViewGroup group) : this()
148 public ListViewItem(string text, ListViewGroup group) : this(text)
153 public ListViewItem(string[] items, ListViewGroup group) : this(items)
158 public ListViewItem(ListViewSubItem[] subItems, int imageIndex, ListViewGroup group)
159 : this(subItems, imageIndex)
164 public ListViewItem(ListViewSubItem[] subItems, string imageKey, ListViewGroup group)
165 : this(subItems, imageKey)
170 public ListViewItem(string text, int imageIndex, ListViewGroup group)
171 : this(text, imageIndex)
176 public ListViewItem(string text, string imageKey, ListViewGroup group)
177 : this(text, imageKey)
182 public ListViewItem(string[] items, int imageIndex, ListViewGroup group)
183 : this(items, imageIndex)
188 public ListViewItem(string[] items, string imageKey, ListViewGroup group)
189 : this(items, imageKey)
194 public ListViewItem(string[] items, int imageIndex, Color foreColor, Color backColor,
195 Font font, ListViewGroup group)
196 : this(items, imageIndex, foreColor, backColor, font)
201 public ListViewItem(string[] items, string imageKey, Color foreColor, Color backColor,
202 Font font, ListViewGroup group)
203 : this(items, imageKey, foreColor, backColor, font)
208 #endregion // Public Constructors
210 #region Public Instance Properties
211 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
212 public Color BackColor {
214 if (sub_items.Count > 0)
215 return sub_items[0].BackColor;
218 return owner.BackColor;
220 return ThemeEngine.Current.ColorWindow;
223 set { sub_items[0].BackColor = value; }
227 public Rectangle Bounds {
229 return GetBounds (ItemBoundsPortion.Entire);
233 [DefaultValue (false)]
234 [RefreshProperties (RefreshProperties.Repaint)]
235 public bool Checked {
236 get { return is_checked; }
238 if (is_checked == value)
244 // force re-population of list
245 owner.CheckedItems.Reset ();
253 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
254 public bool Focused {
255 get { return is_focused; }
257 if (is_focused == value)
270 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
275 else if (owner != null)
278 return ThemeEngine.Current.DefaultFont;
292 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
293 public Color ForeColor {
295 if (sub_items.Count > 0)
296 return sub_items[0].ForeColor;
299 return owner.ForeColor;
301 return ThemeEngine.Current.ColorWindowText;
303 set { sub_items[0].ForeColor = value; }
307 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
308 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
309 typeof (System.Drawing.Design.UITypeEditor))]
312 [RefreshProperties (RefreshProperties.Repaint)]
313 // [TypeConverter (typeof (NoneExcludedImageIndexConverter))]
315 [TypeConverter (typeof (ImageIndexConverter))]
317 public int ImageIndex {
318 get { return image_index; }
321 throw new ArgumentException ("Invalid ImageIndex. It must be greater than or equal to -1.");
325 image_key = String.Empty;
336 [LocalizableAttribute (true)]
337 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
338 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
339 typeof (System.Drawing.Design.UITypeEditor))]
340 [RefreshProperties (RefreshProperties.Repaint)]
341 // XXX [TypeConverter (typeof (ImageKeyConverter))
342 public string ImageKey {
347 image_key = value == null ? String.Empty : value;
358 public ImageList ImageList {
362 else if (owner.View == View.LargeIcon)
363 return owner.large_image_list;
365 return owner.small_image_list;
375 return owner.Items.IndexOf (this);
380 public ListView ListView {
381 get { return owner; }
387 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
393 name = value == null ? String.Empty : value;
399 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
400 public bool Selected {
401 get { return selected; }
403 if (selected == value)
407 if (value && !owner.MultiSelect)
408 owner.SelectedItems.Clear ();
410 // force re-population of list
411 owner.SelectedItems.Reset ();
413 owner.OnSelectedIndexChanged ();
422 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
423 typeof (System.Drawing.Design.UITypeEditor))]
426 [RefreshProperties (RefreshProperties.Repaint)]
427 // XXX [RelatedImageListAttribute ("ListView.StateImageList")]
428 // XXX [TypeConverter (typeof (NoneExcludedImageIndexConverter))]
430 [TypeConverter (typeof (ImageIndexConverter))]
432 public int StateImageIndex {
433 get { return state_image_index; }
435 if (value < -1 || value > 14)
436 throw new ArgumentOutOfRangeException ("Invalid StateImageIndex. It must be in the range of [-1, 14].");
438 state_image_index = value;
442 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
444 [Editor ("System.Windows.Forms.Design.ListViewSubItemCollectionEditor, " + Consts.AssemblySystem_Design,
445 typeof (System.Drawing.Design.UITypeEditor))]
447 public ListViewSubItemCollection SubItems {
448 get { return sub_items; }
452 [DefaultValue (null)]
453 [Localizable (false)]
454 [TypeConverter (typeof (StringConverter))]
461 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
464 if (this.sub_items.Count > 0)
465 return this.sub_items [0].Text;
470 if (sub_items [0].Text == value)
473 sub_items [0].Text = value;
481 [DefaultValue (true)]
482 public bool UseItemStyleForSubItems {
483 get { return use_item_style; }
484 set { use_item_style = value; }
488 [LocalizableAttribute(true)]
489 [DefaultValue (null)]
490 public ListViewGroup Group {
491 get { return this.group; }
494 if (this.group != value)
498 value.Items.Add(this);
500 if (this.group != null)
501 this.group.Items.Remove(this);
507 if(this.group != null)
508 this.group.Items.Remove(this);
515 #endregion // Public Instance Properties
517 #region Public Instance Methods
518 public void BeginEdit ()
520 if (owner != null && owner.LabelEdit) {
521 owner.item_control.BeginEdit (this);
524 // if (owner != null && owner.LabelEdit
525 // && owner.Activation == ItemActivation.Standard)
528 // throw new InvalidOperationException ();
531 public virtual object Clone ()
533 ListViewItem clone = new ListViewItem ();
534 clone.image_index = this.image_index;
535 clone.is_checked = this.is_checked;
536 clone.is_focused = this.is_focused;
537 clone.selected = this.selected;
538 clone.font = this.font;
539 clone.state_image_index = this.state_image_index;
540 clone.sub_items = new ListViewSubItemCollection (this);
542 foreach (ListViewSubItem subItem in this.sub_items)
543 clone.sub_items.Add (subItem.Text, subItem.ForeColor,
544 subItem.BackColor, subItem.Font);
545 clone.tag = this.tag;
546 clone.use_item_style = this.use_item_style;
555 public virtual void EnsureVisible ()
557 if (this.owner != null) {
558 owner.EnsureVisible (owner.Items.IndexOf (this));
562 public Rectangle GetBounds (ItemBoundsPortion portion)
565 return Rectangle.Empty;
570 case ItemBoundsPortion.Icon:
574 case ItemBoundsPortion.Label:
578 case ItemBoundsPortion.ItemOnly:
582 case ItemBoundsPortion.Entire:
587 throw new ArgumentException ("Invalid value for portion.");
590 Point item_loc = owner.GetItemLocation (Index);
591 rect.X += item_loc.X;
592 rect.Y += item_loc.Y;
596 void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
601 public virtual void Remove ()
606 owner.item_control.CancelEdit (this);
607 owner.Items.Remove (this);
611 public override string ToString ()
613 return string.Format ("ListViewItem: {0}", this.Text);
615 #endregion // Public Instance Methods
617 #region Protected Methods
618 protected virtual void Deserialize (SerializationInfo info, StreamingContext context)
623 protected virtual void Serialize (SerializationInfo info, StreamingContext context)
627 #endregion // Protected Methods
629 #region Private Internal Methods
630 internal Rectangle CheckRectReal {
632 Rectangle rect = checkbox_rect;
633 Point item_loc = owner.GetItemLocation (Index);
634 rect.X += item_loc.X;
635 rect.Y += item_loc.Y;
640 internal ListView Owner {
649 private void Invalidate ()
651 if (owner == null || owner.item_control == null)
654 owner.item_control.Invalidate (Bounds);
657 internal void Layout ()
661 Size text_size = owner.text_size;
663 checkbox_rect = Rectangle.Empty;
664 if (owner.CheckBoxes)
665 checkbox_rect.Size = owner.CheckBoxSize;
667 switch (owner.View) {
669 // LAMESPEC: MSDN says, "In all views except the details
670 // view of the ListView, this value specifies the same
671 // bounding rectangle as the Entire value." Actually, it
672 // returns same bounding rectangles for Item and Entire
673 // values in the case of Details view.
675 icon_rect = label_rect = Rectangle.Empty;
676 icon_rect.X = checkbox_rect.Width + 2;
677 item_ht = owner.ItemSize.Height;
679 if (owner.SmallImageList != null)
680 icon_rect.Width = owner.SmallImageList.ImageSize.Width;
682 label_rect.Height = icon_rect.Height = item_ht;
683 checkbox_rect.Y = item_ht - checkbox_rect.Height;
685 label_rect.X = icon_rect.Right + 1;
687 if (owner.Columns.Count > 0)
688 label_rect.Width = owner.Columns [0].Wd - label_rect.X;
690 label_rect.Width = text_size.Width;
692 item_rect = total = Rectangle.Union
693 (Rectangle.Union (checkbox_rect, icon_rect), label_rect);
694 bounds.Size = total.Size;
696 // Take into account the rest of columns. First column
697 // is already taken into account above.
698 for (int i = 1; i < owner.Columns.Count; i++) {
699 item_rect.Width += owner.Columns [i].Wd;
700 bounds.Width += owner.Columns [i].Wd;
705 label_rect = icon_rect = Rectangle.Empty;
707 SizeF sz = owner.DeviceContext.MeasureString (Text, Font);
708 if ((int) sz.Width > text_size.Width) {
710 int text_width = text_size.Width;
711 StringFormat format = new StringFormat ();
712 format.Alignment = StringAlignment.Center;
713 sz = owner.DeviceContext.MeasureString (Text, Font, text_width, format);
714 text_size.Height = (int) sz.Height;
716 text_size.Height = 2 * (int) sz.Height;
719 if (owner.LargeImageList != null) {
720 icon_rect.Width = owner.LargeImageList.ImageSize.Width;
721 icon_rect.Height = owner.LargeImageList.ImageSize.Height;
724 if (checkbox_rect.Height > icon_rect.Height)
725 icon_rect.Y = checkbox_rect.Height - icon_rect.Height;
727 checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height;
729 if (text_size.Width <= icon_rect.Width) {
730 icon_rect.X = checkbox_rect.Width + 1;
731 label_rect.X = icon_rect.X + (icon_rect.Width - text_size.Width) / 2;
732 label_rect.Y = icon_rect.Bottom + 2;
733 label_rect.Size = text_size;
735 int centerX = text_size.Width / 2;
736 icon_rect.X = checkbox_rect.Width + 1 + centerX - icon_rect.Width / 2;
737 label_rect.X = checkbox_rect.Width + 1;
738 label_rect.Y = icon_rect.Bottom + 2;
739 label_rect.Size = text_size;
742 item_rect = Rectangle.Union (icon_rect, label_rect);
743 total = Rectangle.Union (item_rect, checkbox_rect);
744 bounds.Size = total.Size;
749 label_rect = icon_rect = Rectangle.Empty;
750 icon_rect.X = checkbox_rect.Width + 1;
751 item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height);
753 if (owner.SmallImageList != null) {
754 item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height);
755 icon_rect.Width = owner.SmallImageList.ImageSize.Width;
756 icon_rect.Height = owner.SmallImageList.ImageSize.Height;
759 checkbox_rect.Y = item_ht - checkbox_rect.Height;
760 label_rect.X = icon_rect.Right + 1;
761 label_rect.Width = text_size.Width;
762 label_rect.Height = icon_rect.Height = item_ht;
764 item_rect = Rectangle.Union (icon_rect, label_rect);
765 total = Rectangle.Union (item_rect, checkbox_rect);
766 bounds.Size = total.Size;
770 label_rect = icon_rect = Rectangle.Empty;
772 if (owner.LargeImageList != null) {
773 icon_rect.Width = owner.LargeImageList.ImageSize.Width;
774 icon_rect.Height = owner.LargeImageList.ImageSize.Height;
778 SizeF tsize = owner.DeviceContext.MeasureString (Text, Font);
780 // Set initial values for subitem's layout
781 int total_height = (int)Math.Ceiling (tsize.Height);
782 int max_subitem_width = (int)Math.Ceiling (tsize.Width);
783 SubItems [0].bounds.Height = total_height;
785 int count = Math.Min (owner.Columns.Count, SubItems.Count);
786 for (int i = 1; i < count; i++) { // Ignore first column and first subitem
787 ListViewSubItem sub_item = SubItems [i];
788 if (sub_item.Text == null || sub_item.Text.Length == 0)
791 tsize = owner.DeviceContext.MeasureString (sub_item.Text, sub_item.Font);
793 int width = (int)Math.Ceiling (tsize.Width);
795 if (width > max_subitem_width)
796 max_subitem_width = width;
798 int height = (int)Math.Ceiling (tsize.Height);
799 total_height += height + separation;
801 sub_item.bounds.Height = height;
805 label_rect.X = icon_rect.Right + 4;
806 label_rect.Y = owner.TileSize.Height / 2 - total_height / 2;
807 label_rect.Width = max_subitem_width;
808 label_rect.Height = total_height;
810 // Second pass for assigning bounds. This time take first subitem into account.
811 int current_y = label_rect.Y;
812 for (int j = 0; j < count; j++) {
813 ListViewSubItem sub_item = SubItems [j];
814 if (sub_item.Text == null || sub_item.Text.Length == 0)
817 sub_item.SetBounds (label_rect.X, current_y, max_subitem_width, sub_item.bounds.Height);
818 current_y += sub_item.Bounds.Height + separation;
821 item_rect = Rectangle.Union (icon_rect, label_rect);
822 bounds.Size = item_rect.Size;
828 #endregion // Private Internal Methods
832 [DefaultProperty ("Text")]
833 [DesignTimeVisible (false)]
835 [ToolboxItem (false)]
836 [TypeConverter (typeof(ListViewSubItemConverter))]
837 public class ListViewSubItem
839 private Color back_color;
841 private Color fore_color;
842 internal ListViewItem owner;
843 private string text = string.Empty;
845 private string name = String.Empty;
847 internal Rectangle bounds;
850 #region Public Constructors
851 public ListViewSubItem ()
855 public ListViewSubItem (ListViewItem owner, string text)
856 : this (owner, text, ThemeEngine.Current.ColorWindowText,
857 ThemeEngine.Current.ColorWindow, null)
861 public ListViewSubItem (ListViewItem owner, string text, Color foreColor,
862 Color backColor, Font font)
866 this.fore_color = foreColor;
867 this.back_color = backColor;
870 #endregion // Public Constructors
872 #region Public Instance Properties
873 public Color BackColor {
874 get { return back_color; }
882 public Rectangle Bounds {
884 Rectangle retval = bounds;
886 retval.X += owner.Bounds.X;
887 retval.Y += owner.Bounds.Y;
900 else if (owner != null)
902 return ThemeEngine.Current.DefaultFont;
912 public Color ForeColor {
913 get { return fore_color; }
927 name = value == null ? String.Empty : value;
931 [TypeConverter (typeof (StringConverter))]
932 [BindableAttribute (true)]
933 [DefaultValue (null)]
934 [Localizable (false)]
960 #endregion // Public Instance Properties
962 #region Public Methods
963 public void ResetStyle ()
965 font = ThemeEngine.Current.DefaultFont;
966 back_color = ThemeEngine.Current.DefaultControlBackColor;
967 fore_color = ThemeEngine.Current.DefaultControlForeColor;
971 public override string ToString ()
973 return string.Format ("ListViewSubItem {{0}}", text);
975 #endregion // Public Methods
978 #region Private Methods
979 private void Invalidate ()
981 if (owner == null || owner.owner == null)
984 owner.owner.Invalidate ();
988 internal int Height {
990 return bounds.Height;
994 internal void SetBounds (int x, int y, int width, int height)
996 bounds = new Rectangle (x, y, width, height);
999 #endregion // Private Methods
1002 public class ListViewSubItemCollection : IList, ICollection, IEnumerable
1004 private ArrayList list;
1005 internal ListViewItem owner;
1007 #region Public Constructors
1008 public ListViewSubItemCollection (ListViewItem owner)
1011 this.list = new ArrayList ();
1013 #endregion // Public Constructors
1015 #region Public Properties
1018 get { return list.Count; }
1021 public bool IsReadOnly {
1022 get { return false; }
1025 public ListViewSubItem this [int index] {
1026 get { return (ListViewSubItem) list [index]; }
1028 value.owner = this.owner;
1029 list [index] = value;
1034 public virtual ListViewSubItem this [string key] {
1036 int idx = IndexOfKey (key);
1040 return (ListViewSubItem) list [idx];
1045 bool ICollection.IsSynchronized {
1046 get { return list.IsSynchronized; }
1049 object ICollection.SyncRoot {
1050 get { return list.SyncRoot; }
1053 bool IList.IsFixedSize {
1054 get { return list.IsFixedSize; }
1057 object IList.this [int index] {
1058 get { return this [index]; }
1060 if (! (value is ListViewSubItem))
1061 throw new ArgumentException ("Not of type ListViewSubItem", "value");
1062 this [index] = (ListViewSubItem) value;
1065 #endregion // Public Properties
1067 #region Public Methods
1068 public ListViewSubItem Add (ListViewSubItem item)
1070 item.owner = this.owner;
1075 public ListViewSubItem Add (string text)
1077 ListViewSubItem item = new ListViewSubItem (this.owner, text);
1082 public ListViewSubItem Add (string text, Color foreColor,
1083 Color backColor, Font font)
1085 ListViewSubItem item = new ListViewSubItem (this.owner, text,
1086 foreColor, backColor, font);
1091 public void AddRange (ListViewSubItem [] items)
1094 throw new ArgumentNullException ("items");
1096 foreach (ListViewSubItem item in items) {
1103 public void AddRange (string [] items)
1106 throw new ArgumentNullException ("items");
1108 foreach (string item in items) {
1115 public void AddRange (string [] items, Color foreColor,
1116 Color backColor, Font font)
1119 throw new ArgumentNullException ("items");
1121 foreach (string item in items) {
1124 this.Add (item, foreColor, backColor, font);
1128 public void Clear ()
1133 public bool Contains (ListViewSubItem item)
1135 return list.Contains (item);
1139 public virtual bool ContainsKey (string key)
1141 return IndexOfKey (key) != -1;
1145 public IEnumerator GetEnumerator ()
1147 return list.GetEnumerator ();
1150 void ICollection.CopyTo (Array dest, int index)
1152 list.CopyTo (dest, index);
1155 int IList.Add (object item)
1157 if (! (item is ListViewSubItem)) {
1158 throw new ArgumentException ("Not of type ListViewSubItem", "item");
1161 ListViewSubItem sub_item = (ListViewSubItem) item;
1162 sub_item.owner = this.owner;
1163 return list.Add (sub_item);
1166 bool IList.Contains (object subItem)
1168 if (! (subItem is ListViewSubItem)) {
1169 throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
1172 return this.Contains ((ListViewSubItem) subItem);
1175 int IList.IndexOf (object subItem)
1177 if (! (subItem is ListViewSubItem)) {
1178 throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
1181 return this.IndexOf ((ListViewSubItem) subItem);
1184 void IList.Insert (int index, object item)
1186 if (! (item is ListViewSubItem)) {
1187 throw new ArgumentException ("Not of type ListViewSubItem", "item");
1190 this.Insert (index, (ListViewSubItem) item);
1193 void IList.Remove (object item)
1195 if (! (item is ListViewSubItem)) {
1196 throw new ArgumentException ("Not of type ListViewSubItem", "item");
1199 this.Remove ((ListViewSubItem) item);
1202 public int IndexOf (ListViewSubItem subItem)
1204 return list.IndexOf (subItem);
1208 public virtual int IndexOfKey (string key)
1210 if (key == null || key.Length == 0)
1213 for (int i = 0; i < list.Count; i++) {
1214 ListViewSubItem l = (ListViewSubItem) list [i];
1215 if (String.Compare (l.Name, key, true) == 0)
1223 public void Insert (int index, ListViewSubItem item)
1225 item.owner = this.owner;
1226 list.Insert (index, item);
1229 public void Remove (ListViewSubItem item)
1235 public virtual void RemoveByKey (string key)
1237 int idx = IndexOfKey (key);
1243 public void RemoveAt (int index)
1245 list.RemoveAt (index);
1247 #endregion // Public Methods
1249 #endregion // Subclasses