2006-12-11 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ListViewItem.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Ravindra (rkumar@novell.com)
24 //      Mike Kestner <mkestner@novell.com>
25
26
27
28 // NOT COMPLETE
29
30
31 using System.Collections;
32 using System.ComponentModel;
33 using System.Drawing;
34 using System.Runtime.Serialization;
35
36 namespace System.Windows.Forms
37 {
38         [DefaultProperty ("Text")]
39         [DesignTimeVisible (false)]
40         [Serializable]
41         [ToolboxItem (false)]
42         [TypeConverter (typeof (ListViewItemConverter))]
43         public class ListViewItem : ICloneable, ISerializable
44         {
45                 #region Instance Variables
46                 private int image_index = -1;
47                 private bool is_checked = false;
48                 private bool is_focused = false;
49                 private int state_image_index = -1;
50                 private ListViewSubItemCollection sub_items;
51                 private object tag;
52                 private bool use_item_style = true;
53 #if NET_2_0
54                 private string name = String.Empty;
55 #endif
56
57                 Rectangle bounds;
58                 Rectangle checkbox_rect;        // calculated by CalcListViewItem method
59                 Rectangle icon_rect;
60                 Rectangle item_rect;
61                 Rectangle label_rect;
62                 ListView owner;
63                 Font font;
64                 bool selected;
65
66                 internal int row;
67                 internal int col;
68
69                 #endregion Instance Variables
70
71                 #region Public Constructors
72                 public ListViewItem ()
73                 {
74                         this.sub_items = new ListViewSubItemCollection (this);
75                         this.sub_items.Add ("");                        
76                 }
77
78                 public ListViewItem (string text) : this (text, -1)
79                 {
80                 }
81
82                 public ListViewItem (string [] items) : this (items, -1)
83                 {
84                 }
85
86                 public ListViewItem (ListViewItem.ListViewSubItem [] subItems, int imageIndex)
87                 {
88                         this.sub_items = new ListViewSubItemCollection (this);
89                         this.sub_items.AddRange (subItems);
90                         this.image_index = imageIndex;
91                 }
92
93                 public ListViewItem (string text, int imageIndex)
94                 {
95                         this.image_index = imageIndex;
96                         this.sub_items = new ListViewSubItemCollection (this);
97                         this.sub_items.Add (text);
98                 }
99
100                 public ListViewItem (string [] items, int imageIndex)
101                 {
102                         this.sub_items = new ListViewSubItemCollection (this);
103                         this.sub_items.AddRange (items);
104                         this.image_index = imageIndex;
105                 }
106
107                 public ListViewItem (string [] items, int imageIndex, Color foreColor, 
108                                      Color backColor, Font font)
109                 {
110                         this.sub_items = new ListViewSubItemCollection (this);
111                         this.sub_items.AddRange (items);
112                         this.image_index = imageIndex;
113                         ForeColor = foreColor;
114                         BackColor = backColor;
115                         this.font = font;
116                 }
117                 #endregion      // Public Constructors
118
119                 #region Public Instance Properties
120                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
121                 public Color BackColor {
122                         get {
123                                 if (sub_items.Count > 0)
124                                         return sub_items[0].BackColor;
125
126                                 if (owner != null)
127                                         return owner.BackColor;
128                                 
129                                 return ThemeEngine.Current.ColorWindow;
130                         }
131
132                         set { sub_items[0].BackColor = value; }
133                 }
134
135                 [Browsable (false)]
136                 public Rectangle Bounds {
137                         get {
138                                 return GetBounds (ItemBoundsPortion.Entire);
139                         }
140                 }
141
142                 [DefaultValue (false)]
143                 [RefreshProperties (RefreshProperties.Repaint)]
144                 public bool Checked {
145                         get { return is_checked; }
146                         set { 
147                                 if (is_checked == value)
148                                         return;
149                                 
150                                 is_checked = value;
151
152                                 if (owner != null) {
153                                         // force re-population of list
154                                         owner.CheckedItems.Reset ();
155                                         Layout ();
156                                 }                       
157                                 Invalidate ();
158                         }
159                 }
160
161                 [Browsable (false)]
162                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
163                 public bool Focused {
164                         get { return is_focused; }
165                         set {   
166                                 if (is_focused == value)
167                                         return;
168
169                                 is_focused = value; 
170
171                                 Invalidate ();
172                                 if (owner != null)
173                                         Layout ();
174                                 Invalidate ();
175                         }
176                 }
177
178                 [Localizable (true)]
179                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
180                 public Font Font {
181                         get {
182                                 if (font != null)
183                                         return font;
184                                 else if (owner != null)
185                                         return owner.Font;
186
187                                 return ThemeEngine.Current.DefaultFont;
188                         }
189                         set {   
190                                 if (font == value)
191                                         return;
192
193                                 font = value; 
194
195                                 if (owner != null)
196                                         Layout ();
197                                 Invalidate ();
198                         }
199                 }
200
201                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
202                 public Color ForeColor {
203                         get {
204                                 if (sub_items.Count > 0)
205                                         return sub_items[0].ForeColor;
206
207                                 if (owner != null)
208                                         return owner.ForeColor;
209
210                                 return ThemeEngine.Current.ColorWindowText;
211                         }
212                         set { sub_items[0].ForeColor = value; }
213                 }
214
215                 [DefaultValue (-1)]
216                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
217                 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
218                          typeof (System.Drawing.Design.UITypeEditor))]
219                 [Localizable (true)]
220                 [TypeConverter (typeof (ImageIndexConverter))]
221                 public int ImageIndex {
222                         get { return image_index; }
223                         set {
224                                 if (value < -1)
225                                         throw new ArgumentException ("Invalid ImageIndex. It must be greater than or equal to -1.");
226                                 
227                                 image_index = value;
228
229                                 if (owner != null)
230                                         Layout ();
231                                 Invalidate ();
232                         }
233                 }
234
235                 [Browsable (false)]
236                 public ImageList ImageList {
237                         get {
238                                 if (owner == null)
239                                         return null;
240                                 else if (owner.View == View.LargeIcon)
241                                         return owner.large_image_list;
242                                 else
243                                         return owner.small_image_list;
244                         }
245                 }
246
247                 [Browsable (false)]
248                 public int Index {
249                         get {
250                                 if (owner == null)
251                                         return -1;
252                                 else
253                                         return owner.Items.IndexOf (this);
254                         }
255                 }
256
257                 [Browsable (false)]
258                 public ListView ListView {
259                         get { return owner; }
260                 }
261
262 #if NET_2_0
263                 [Browsable (false)]
264                 [Localizable (true)]
265                 public string Name {
266                         get {
267                                 return name;
268                         }
269                         set {
270                                 name = value == null ? String.Empty : name;
271                         }
272                 }
273 #endif
274
275                 [Browsable (false)]
276                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
277                 public bool Selected {
278                         get { return selected; }
279                         set {
280                                 if (selected == value)
281                                         return;
282
283                                 if (owner != null) {
284                                         if (value && !owner.MultiSelect)
285                                                 owner.SelectedItems.Clear ();
286                                         selected = value;
287                                         // force re-population of list
288                                         owner.SelectedItems.Reset ();
289                                         Layout ();
290                                         owner.OnSelectedIndexChanged ();
291                                 } else {
292                                         selected = value;
293                                 }
294                                 Invalidate ();
295                         }
296                 }
297
298                 [DefaultValue (-1)]
299                 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design,
300                          typeof (System.Drawing.Design.UITypeEditor))]
301                 [Localizable (true)]
302                 [TypeConverter (typeof (ImageIndexConverter))]
303                 public int StateImageIndex {
304                         get { return state_image_index; }
305                         set {
306                                 if (value < -1 || value > 14)
307                                         throw new ArgumentOutOfRangeException ("Invalid StateImageIndex. It must be in the range of [-1, 14].");
308
309                                 state_image_index = value;
310                         }
311                 }
312
313                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
314                 public ListViewSubItemCollection SubItems {
315                         get { return sub_items; }
316                 }
317
318                 [Bindable (true)]
319                 [DefaultValue (null)]
320                 [Localizable (false)]
321                 [TypeConverter (typeof (StringConverter))]
322                 public object Tag {
323                         get { return tag; }
324                         set { tag = value; }
325                 }
326
327                 [Localizable (true)]
328                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
329                 public string Text {
330                         get {
331                                 if (this.sub_items.Count > 0)
332                                         return this.sub_items [0].Text;
333                                 else
334                                         return "";
335                         }
336                         set { 
337                                 if (sub_items [0].Text == value)
338                                         return;
339
340                                 sub_items [0].Text = value; 
341
342                                 if (owner != null)
343                                         Layout ();
344                                 Invalidate ();
345                         }
346                 }
347
348                 [DefaultValue (true)]
349                 public bool UseItemStyleForSubItems {
350                         get { return use_item_style; }
351                         set { use_item_style = value; }
352                 }
353                 #endregion      // Public Instance Properties
354
355                 #region Public Instance Methods
356                 public void BeginEdit ()
357                 {
358                         if (owner != null && owner.LabelEdit) {
359                                 owner.item_control.BeginEdit (this);
360                         }
361                         // FIXME: TODO
362                         // if (owner != null && owner.LabelEdit 
363                         //    && owner.Activation == ItemActivation.Standard)
364                         // allow editing
365                         // else
366                         // throw new InvalidOperationException ();
367                 }
368
369                 public virtual object Clone ()
370                 {
371                         ListViewItem clone = new ListViewItem ();
372                         clone.image_index = this.image_index;
373                         clone.is_checked = this.is_checked;
374                         clone.is_focused = this.is_focused;
375                         clone.selected = this.selected;
376                         clone.font = this.font;
377                         clone.state_image_index = this.state_image_index;
378                         clone.sub_items = new ListViewSubItemCollection (this);
379                         
380                         foreach (ListViewSubItem subItem in this.sub_items)
381                                 clone.sub_items.Add (subItem.Text, subItem.ForeColor,
382                                                      subItem.BackColor, subItem.Font);
383                         clone.tag = this.tag;
384                         clone.use_item_style = this.use_item_style;
385                         clone.owner = null;
386 #if NET_2_0
387                         clone.name = name;
388 #endif
389
390                         return clone;
391                 }
392
393                 public virtual void EnsureVisible ()
394                 {
395                         if (this.owner != null) {
396                                 owner.EnsureVisible (owner.Items.IndexOf (this));
397                         }
398                 }
399
400                 public Rectangle GetBounds (ItemBoundsPortion portion)
401                 {
402                         if (owner == null)
403                                 return Rectangle.Empty;
404                                 
405                         Rectangle rect;
406
407                         switch (portion) {
408                         case ItemBoundsPortion.Icon:
409                                 rect = icon_rect;
410                                 break;
411
412                         case ItemBoundsPortion.Label:
413                                 rect = label_rect;
414                                 break;
415
416                         case ItemBoundsPortion.ItemOnly:
417                                 rect = item_rect;
418                                 break;
419
420                         case ItemBoundsPortion.Entire:
421                                 rect = bounds;
422                                 rect.X -= owner.h_marker;
423                                 rect.Y -= owner.v_marker;
424                                 return rect;                            
425
426                         default:
427                                 throw new ArgumentException ("Invalid value for portion.");
428                         }
429
430                         rect.X += bounds.X - owner.h_marker;
431                         rect.Y += bounds.Y - owner.v_marker;
432                         return rect;
433                 }
434
435                 void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
436                 {
437                         // FIXME: TODO
438                 }
439
440                 public virtual void Remove ()
441                 {
442                         if (owner != null)
443                                 owner.Items.Remove (this);
444                         owner = null;
445                 }
446
447                 public override string ToString ()
448                 {
449                         return string.Format ("ListViewItem: {0}", this.Text);
450                 }
451                 #endregion      // Public Instance Methods
452
453                 #region Protected Methods
454                 protected virtual void Deserialize (SerializationInfo info, StreamingContext context)
455                 {
456                         // FIXME: TODO
457                 }
458
459                 protected virtual void Serialize (SerializationInfo info, StreamingContext context)
460                 {
461                         // FIXME: TODO
462                 }
463                 #endregion      // Protected Methods
464
465                 #region Private Internal Methods
466                 internal Rectangle CheckRectReal {
467                         get {
468                                 Rectangle rect = checkbox_rect;
469                                 rect.X += bounds.X - owner.h_marker;
470                                 rect.Y += bounds.Y - owner.v_marker;
471                                 return rect;
472                         }
473                 }
474                 
475                 internal Point Location {
476                         set {
477                                 if (bounds.X == value.X && bounds.Y == value.Y)
478                                         return;
479
480                                 Rectangle prev = Bounds;
481                                 bounds.X = value.X;
482                                 bounds.Y = value.Y;
483                                 if (owner != null) {
484                                         if (prev != Rectangle.Empty)
485                                                 owner.item_control.Invalidate (prev);
486                                         owner.item_control.Invalidate (Bounds);
487                                 }
488                         }
489                 }
490
491                 internal ListView Owner {
492                         set {
493                                 if (owner == value)
494                                         return;
495
496                                 owner = value;
497                                 if (owner != null)
498                                         Layout ();
499                                 Invalidate ();
500                         }
501                 }
502
503                 private void Invalidate ()
504                 {
505                         if (owner == null || owner.item_control == null)
506                                 return;
507
508                         owner.item_control.Invalidate (Bounds);
509                 }
510
511                 internal void Layout ()
512                 {
513                         int item_ht;
514                         Rectangle total;
515                         Size text_size = owner.text_size;
516                         
517                         checkbox_rect = Rectangle.Empty;
518                         if (owner.CheckBoxes)
519                                 checkbox_rect.Size = owner.CheckBoxSize;
520
521                         switch (owner.View) {
522                         case View.Details:
523                                 // LAMESPEC: MSDN says, "In all views except the details
524                                 // view of the ListView, this value specifies the same
525                                 // bounding rectangle as the Entire value." Actually, it
526                                 // returns same bounding rectangles for Item and Entire
527                                 // values in the case of Details view.
528
529                                 icon_rect = label_rect = Rectangle.Empty;
530                                 icon_rect.X = checkbox_rect.Width + 2;
531                                 item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height);
532
533                                 if (owner.SmallImageList != null) {
534                                         item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height);
535                                         icon_rect.Width = owner.SmallImageList.ImageSize.Width;
536                                 }
537
538                                 label_rect.Height = icon_rect.Height = item_ht;
539                                 checkbox_rect.Y = item_ht - checkbox_rect.Height;
540
541                                 label_rect.X = icon_rect.Right + 1;
542
543                                 if (owner.Columns.Count > 0)
544                                         label_rect.Width = Math.Max (text_size.Width, owner.Columns[0].Wd);
545                                 else
546                                         label_rect.Width = text_size.Width;
547
548                                 item_rect = total = Rectangle.Union
549                                         (Rectangle.Union (checkbox_rect, icon_rect), label_rect);
550                                 bounds.Size = total.Size;
551
552                                 // Take into account the rest of columns. First column
553                                 // is already taken into account above.
554                                 for (int i = 1; i < owner.Columns.Count; i++) {
555                                         item_rect.Width += owner.Columns [i].Wd;
556                                         bounds.Width += owner.Columns [i].Wd;
557                                 }
558                                 break;
559
560                         case View.LargeIcon:
561                                 label_rect = icon_rect = Rectangle.Empty;
562
563                                 SizeF sz = owner.DeviceContext.MeasureString (Text, Font);
564                                 if ((int) sz.Width > text_size.Width) {
565                                         if (Focused) {
566                                                 int text_width = text_size.Width;
567                                                 StringFormat format = new StringFormat ();
568                                                 format.Alignment = StringAlignment.Center;
569                                                 sz = owner.DeviceContext.MeasureString (Text, Font, text_width, format);
570                                                 text_size.Height = (int) sz.Height;
571                                         } else
572                                                 text_size.Height = 2 * (int) sz.Height;
573                                 }
574
575                                 if (owner.LargeImageList != null) {
576                                         icon_rect.Width = owner.LargeImageList.ImageSize.Width;
577                                         icon_rect.Height = owner.LargeImageList.ImageSize.Height;
578                                 }
579
580                                 if (checkbox_rect.Height > icon_rect.Height)
581                                         icon_rect.Y = checkbox_rect.Height - icon_rect.Height;
582                                 else
583                                         checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height;
584
585                                 if (text_size.Width <= icon_rect.Width) {
586                                         icon_rect.X = checkbox_rect.Width + 1;
587                                         label_rect.X = icon_rect.X + (icon_rect.Width - text_size.Width) / 2;
588                                         label_rect.Y = icon_rect.Bottom + 2;
589                                         label_rect.Size = text_size;
590                                 } else {
591                                         int centerX = text_size.Width / 2;
592                                         icon_rect.X = checkbox_rect.Width + 1 + centerX - icon_rect.Width / 2;
593                                         label_rect.X = checkbox_rect.Width + 1;
594                                         label_rect.Y = icon_rect.Bottom + 2;
595                                         label_rect.Size = text_size;
596                                 }
597
598                                 item_rect = Rectangle.Union (icon_rect, label_rect);
599                                 total = Rectangle.Union (item_rect, checkbox_rect);
600                                 bounds.Size = total.Size;
601                                 break;
602
603                         case View.List:
604                         case View.SmallIcon:
605                                 label_rect = icon_rect = Rectangle.Empty;
606                                 icon_rect.X = checkbox_rect.Width + 1;
607                                 item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height);
608
609                                 if (owner.SmallImageList != null) {
610                                         item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height);
611                                         icon_rect.Width = owner.SmallImageList.ImageSize.Width;
612                                         icon_rect.Height = owner.SmallImageList.ImageSize.Height;
613                                 }
614
615                                 checkbox_rect.Y = item_ht - checkbox_rect.Height;
616                                 label_rect.X = icon_rect.Right + 1;
617                                 label_rect.Width = text_size.Width;
618                                 label_rect.Height = icon_rect.Height = item_ht;
619
620                                 item_rect = Rectangle.Union (icon_rect, label_rect);
621                                 total = Rectangle.Union (item_rect, checkbox_rect);
622                                 bounds.Size = total.Size;
623                                 break;
624                         }
625                         
626                 }
627                 #endregion      // Private Internal Methods
628
629                 #region Subclasses
630
631                 [DefaultProperty ("Text")]
632                 [DesignTimeVisible (false)]
633                 [Serializable]
634                 [ToolboxItem (false)]
635                 [TypeConverter (typeof(ListViewSubItemConverter))]
636                 public class ListViewSubItem
637                 {
638                         private Color back_color;
639                         private Font font;
640                         private Color fore_color;
641                         internal ListViewItem owner;
642                         private string text;
643                         
644                         #region Public Constructors
645                         public ListViewSubItem ()
646                         {
647                         }
648
649                         public ListViewSubItem (ListViewItem owner, string text)
650                                 : this (owner, text, ThemeEngine.Current.ColorWindowText,
651                                         ThemeEngine.Current.ColorWindow, null)
652                         {
653                         }
654
655                         public ListViewSubItem (ListViewItem owner, string text, Color foreColor,
656                                                 Color backColor, Font font)
657                         {
658                                 this.owner = owner;
659                                 this.text = text;
660                                 this.fore_color = foreColor;
661                                 this.back_color = backColor;
662                                 this.font = font;
663                         }
664                         #endregion // Public Constructors
665
666                         #region Public Instance Properties
667                         public Color BackColor {
668                                 get { return back_color; }
669                                 set { 
670                                         back_color = value; 
671                                         Invalidate ();
672                                     }
673                         }
674
675                         [Localizable (true)]
676                         public Font Font {
677                                 get {
678                                         if (font != null)
679                                                 return font;
680                                         else if (owner != null)
681                                                 return owner.Font;
682                                         return ThemeEngine.Current.DefaultFont;
683                                 }
684                                 set { 
685                                         if (font == value)
686                                                 return;
687                                         font = value; 
688                                         Invalidate ();
689                                     }
690                         }
691
692                         public Color ForeColor {
693                                 get { return fore_color; }
694                                 set { 
695                                         fore_color = value; 
696                                         Invalidate ();
697                                     }
698                         }
699
700                         [Localizable (true)]
701                         public string Text {
702                                 get { return text; }
703                                 set { 
704                                         text = value; 
705                                         Invalidate ();
706                                     }
707                         }
708                         #endregion // Public Instance Properties
709
710                         #region Public Methods
711                         public void ResetStyle ()
712                         {
713                                 font = ThemeEngine.Current.DefaultFont;
714                                 back_color = ThemeEngine.Current.DefaultControlBackColor;
715                                 fore_color = ThemeEngine.Current.DefaultControlForeColor;
716                                 Invalidate ();
717                         }
718
719                         public override string ToString ()
720                         {
721                                 return string.Format ("ListViewSubItem {{0}}", text);
722                         }
723                         #endregion // Public Methods
724
725                         
726                         #region Private Methods
727                         private void Invalidate ()
728                         {
729                                 if (owner == null || owner.owner == null)
730                                         return;
731
732                                 owner.owner.Invalidate ();
733                         }
734                         #endregion // Private Methods
735                 }
736
737                 public class ListViewSubItemCollection : IList, ICollection, IEnumerable
738                 {
739                         private ArrayList list;
740                         internal ListViewItem owner;
741
742                         #region Public Constructors
743                         public ListViewSubItemCollection (ListViewItem owner)
744                         {
745                                 this.owner = owner;
746                                 this.list = new ArrayList ();
747                         }
748                         #endregion // Public Constructors
749
750                         #region Public Properties
751                         [Browsable (false)]
752                         public int Count {
753                                 get { return list.Count; }
754                         }
755
756                         public bool IsReadOnly {
757                                 get { return false; }
758                         }
759
760                         public ListViewSubItem this [int index] {
761                                 get { return (ListViewSubItem) list [index]; }
762                                 set { 
763                                         value.owner = this.owner;
764                                         list [index] = value;
765                                 }
766                         }
767
768                         bool ICollection.IsSynchronized {
769                                 get { return list.IsSynchronized; }
770                         }
771
772                         object ICollection.SyncRoot {
773                                 get { return list.SyncRoot; }
774                         }
775
776                         bool IList.IsFixedSize {
777                                 get { return list.IsFixedSize; }
778                         }
779
780                         object IList.this [int index] {
781                                 get { return this [index]; }
782                                 set {
783                                         if (! (value is ListViewSubItem))
784                                                 throw new ArgumentException ("Not of type ListViewSubItem", "value");
785                                         this [index] = (ListViewSubItem) value;
786                                 }
787                         }
788                         #endregion // Public Properties
789
790                         #region Public Methods
791                         public ListViewSubItem Add (ListViewSubItem item)
792                         {
793                                 item.owner = this.owner;
794                                 list.Add (item);
795                                 return item;
796                         }
797
798                         public ListViewSubItem Add (string text)
799                         {
800                                 ListViewSubItem item = new ListViewSubItem (this.owner, text);
801                                 list.Add (item);
802                                 return item;
803                         }
804
805                         public ListViewSubItem Add (string text, Color foreColor,
806                                                     Color backColor, Font font)
807                         {
808                                 ListViewSubItem item = new ListViewSubItem (this.owner, text,
809                                                                             foreColor, backColor, font);
810                                 list.Add (item);
811                                 return item;
812                         }
813
814                         public void AddRange (ListViewSubItem [] items)
815                         {
816                                 list.Clear ();
817                                 foreach (ListViewSubItem item in items)
818                                         this.Add (item);
819                         }
820
821                         public void AddRange (string [] items)
822                         {
823                                 list.Clear ();
824                                 foreach (string item in items)
825                                         this.Add (item);
826                         }
827
828                         public void AddRange (string [] items, Color foreColor,
829                                               Color backColor, Font font)
830                         {
831                                 list.Clear ();
832                                 foreach (string item in items)
833                                         this.Add (item, foreColor, backColor, font);
834                         }
835
836                         public void Clear ()
837                         {
838                                 list.Clear ();
839                         }
840
841                         public bool Contains (ListViewSubItem item)
842                         {
843                                 return list.Contains (item);
844                         }
845
846                         public IEnumerator GetEnumerator ()
847                         {
848                                 return list.GetEnumerator ();
849                         }
850
851                         void ICollection.CopyTo (Array dest, int index)
852                         {
853                                 list.CopyTo (dest, index);
854                         }
855
856                         int IList.Add (object item)
857                         {
858                                 if (! (item is ListViewSubItem)) {
859                                         throw new ArgumentException ("Not of type ListViewSubItem", "item");
860                                 }
861
862                                 ListViewSubItem sub_item = (ListViewSubItem) item;
863                                 sub_item.owner = this.owner;
864                                 return list.Add (sub_item);
865                         }
866
867                         bool IList.Contains (object subItem)
868                         {
869                                 if (! (subItem is ListViewSubItem)) {
870                                         throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
871                                 }
872
873                                 return this.Contains ((ListViewSubItem) subItem);
874                         }
875
876                         int IList.IndexOf (object subItem)
877                         {
878                                 if (! (subItem is ListViewSubItem)) {
879                                         throw new ArgumentException ("Not of type ListViewSubItem", "subItem");
880                                 }
881
882                                 return this.IndexOf ((ListViewSubItem) subItem);
883                         }
884
885                         void IList.Insert (int index, object item)
886                         {
887                                 if (! (item is ListViewSubItem)) {
888                                         throw new ArgumentException ("Not of type ListViewSubItem", "item");
889                                 }
890
891                                 this.Insert (index, (ListViewSubItem) item);
892                         }
893
894                         void IList.Remove (object item)
895                         {
896                                 if (! (item is ListViewSubItem)) {
897                                         throw new ArgumentException ("Not of type ListViewSubItem", "item");
898                                 }
899
900                                 this.Remove ((ListViewSubItem) item);
901                         }
902
903                         public int IndexOf (ListViewSubItem subItem)
904                         {
905                                 return list.IndexOf (subItem);
906                         }
907
908                         public void Insert (int index, ListViewSubItem item)
909                         {
910                                 item.owner = this.owner;
911                                 list.Insert (index, item);
912                         }
913
914                         public void Remove (ListViewSubItem item)
915                         {
916                                 list.Remove (item);
917                         }
918
919                         public void RemoveAt (int index)
920                         {
921                                 list.RemoveAt (index);
922                         }
923                         #endregion // Public Methods
924                 }
925                 #endregion // Subclasses
926         }
927 }