2 // System.Windows.Forms.ListView.cs
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu), Dennis Hayes (dennish@raytek.com)
6 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
7 // (C) 2002/3 Ximian, Inc
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 - Multiple insertions of the same items should thown an exception
40 using System
.Collections
;
43 using System
.ComponentModel
;
44 using System
.Runtime
.InteropServices
;
47 namespace System
.Windows
.Forms
{
52 public class ListView
: Control
{
54 private ListViewItemCollection itemsCollection
= null;
55 private ColumnHeaderCollection columCol
= null;
56 private bool bInitialised
= false;
57 private View viewMode
= View
.LargeIcon
;
58 private bool bAllowColumnReorder
= false;
59 private SortOrder sortOrder
= SortOrder
.None
;
60 private bool bLabelEdit
= false;
61 private bool bFullRowSelect
= false;
62 private bool bGridLines
= false;
63 private bool bAutoArrange
= true;
64 private bool bLabelWrap
= true;
65 private bool bMultiSelect
= true;
66 private bool bCheckBoxes
= false;
67 private Color backColor
= SystemColors
.Window
;
68 private Color foreColor
= SystemColors
.WindowText
;
69 private SelectedListViewItemCollection selItemsCol
= null;
70 private SelectedIndexCollection selItemIndexs
= null;
71 private CheckedListViewItemCollection chkItemCol
= null;
72 private CheckedIndexCollection chkIndexCol
= null;
73 private ItemActivation activation
= ItemActivation
.Standard
;
74 private ColumnHeaderStyle headerStyle
= ColumnHeaderStyle
.Clickable
;
75 private BorderStyle borderStyle
= BorderStyle
.Fixed3D
;
76 bool bScrollable
= true;
77 bool bHideSelection
= true;
78 bool bHoverSelection
= false;
84 public ListView() : base() {
86 itemsCollection
= new ListViewItemCollection(this);
87 columCol
= new ColumnHeaderCollection(this);
88 selItemsCol
= new SelectedListViewItemCollection(this);
89 selItemIndexs
= new SelectedIndexCollection(this);
90 chkItemCol
= new CheckedListViewItemCollection(this);
91 chkIndexCol
= new CheckedIndexCollection(this);
93 INITCOMMONCONTROLSEX initEx
= new INITCOMMONCONTROLSEX();
94 initEx
.dwICC
= CommonControlInitFlags
.ICC_LISTVIEW_CLASSES
;
95 Win32
.InitCommonControlsEx(initEx
);
97 SubClassWndProc_
= true;
101 // --- Public Properties
104 public ItemActivation Activation
{
105 get {return activation; }
108 ItemActivationCtrl();
113 public ListViewAlignment Alignment
{
116 //throw new NotImplementedException ();
119 //throw new NotImplementedException ();
123 public bool AllowColumnReorder
{
125 get { return bAllowColumnReorder; }
127 ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_HEADERDRAGDROP
, value);
128 bAllowColumnReorder
= value;
133 public bool AutoArrange
{
135 get {return bAutoArrange; }
136 set {bAutoArrange = value;}
139 public override Color BackColor
{
141 get {return backColor; }
149 public override Image BackgroundImage
{
152 return base.BackgroundImage
;
156 base.BackgroundImage
= value;
160 public BorderStyle BorderStyle
{
161 get { return borderStyle; }
162 set { borderStyle = value; }
165 public bool CheckBoxes
{
167 get { return bCheckBoxes; }
169 ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_CHECKBOXES
, value);
174 public CheckedIndexCollection CheckedIndices
{
175 get {return chkIndexCol;}
178 public CheckedListViewItemCollection CheckedItems
{
179 get {return chkItemCol;}
182 public ColumnHeaderCollection Columns
{
183 get {return columCol;}
187 protected override void Dispose(bool disposing
){
188 base.Dispose(disposing
);
192 public override Color ForeColor
{
193 get {return foreColor; }
194 set {foreColor = value;}
197 public bool FullRowSelect
{
199 get { return bFullRowSelect;}
201 ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_FULLROWSELECT
, value);
202 bFullRowSelect
= value;
206 public bool GridLines
{
208 get { return bGridLines;}
210 ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_GRIDLINES
, value);
215 public ColumnHeaderStyle HeaderStyle
{
216 get {return headerStyle; }
217 set {headerStyle = value;}
220 public bool HideSelection
{
221 get {return bHideSelection;}
222 set {bHideSelection=value;}
225 public bool HoverSelection
{
226 get {return bHideSelection;}
228 ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_TRACKSELECT
, value);
229 bHideSelection
=value;
233 public ListView
.ListViewItemCollection Items
{
234 get {return itemsCollection;}
238 public bool LabelEdit
{
239 get {return bLabelEdit;}
240 set {bLabelEdit=value;}
243 public bool LabelWrap
{
244 get {return bLabelWrap;}
245 set {bLabelWrap=value;}
249 public ImageList LargeImageList
{
251 throw new NotImplementedException ();
254 throw new NotImplementedException ();
258 public bool MultiSelect
{
260 get {return bMultiSelect;}
261 set {bMultiSelect=value;}
265 public bool Scrollable
{
266 get {return bScrollable;}
267 set {bScrollable=value;}
270 public ListView
.SelectedIndexCollection SelectedIndices
{
271 get {return selItemIndexs;}
275 public ListView
.SelectedListViewItemCollection SelectedItems
{
276 get {return selItemsCol;}
279 public ImageList SmallImageList
{
281 throw new NotImplementedException ();
284 throw new NotImplementedException ();
288 public SortOrder Sorting
{
290 get {return sortOrder;}
292 SortMsg(value);// Throw an exception if an invalid enum value is given
299 public ImageList StateImageList
{
301 throw new NotImplementedException ();
304 throw new NotImplementedException ();
308 public override string Text
{
318 get {return viewMode;}
322 ViewMode(value); // Throw an exception if an invalid enum value is given
328 // --- Public Methods
331 public void ArrangeIcons() {
332 throw new NotImplementedException ();
335 public void ArrangeIcons(ListViewAlignment
value) {
336 throw new NotImplementedException ();
340 public void BeginUpdate() {
341 throw new NotImplementedException ();
344 public void Clear() {
348 itemsCollection
.Clear();
351 if (!bInitialised
) return;
353 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_DELETEALLITEMS
, 0,0);
358 public void EndUpdate() {
359 throw new NotImplementedException ();
362 public void EnsureVisible(int index
) {
363 throw new NotImplementedException ();
366 public ListViewItem
GetItemAt(int x
, int y
) {
367 throw new NotImplementedException ();
370 public Rectangle
GetItemRect(int index
) {
371 throw new NotImplementedException ();
374 public Rectangle
GetItemRect(int index
, ItemBoundsPortion portion
) {
375 throw new NotImplementedException ();
378 public override string ToString() {
380 return "List View object";
386 public event LabelEditEventHandler AfterLabelEdit
;
387 public event LabelEditEventHandler BeforeLabelEdit
;
388 public event ColumnClickEventHandler ColumnClick
;
389 public event EventHandler ItemActivate
;
392 public event ItemCheckEventHandler ItemCheck
;
393 public event ItemDragEventHandler ItemDrag
;
394 public event EventHandler SelectedIndexChanged
;
397 // --- Protected Properties
399 protected override CreateParams CreateParams
{
402 CreateParams createParams
= base.CreateParams
;
404 createParams
.ClassName
= "SysListView32";
405 createParams
.Style
= ((int)WindowStyles
.WS_CHILD
|(int)WindowStyles
.WS_VISIBLE
|
406 ViewMode(viewMode
)| SortMsg(sortOrder
));
408 if (LabelEdit
) createParams
.Style
|= (int) ListViewFlags
.LVS_EDITLABELS
;
409 if (AutoArrange
) createParams
.Style
|= (int) ListViewFlags
.LVS_AUTOARRANGE
;
410 if (!bLabelWrap
) createParams
.Style
|= (int) ListViewFlags
.LVS_NOLABELWRAP
;
411 if (!bMultiSelect
) createParams
.Style
|= (int) ListViewFlags
.LVS_SINGLESEL
;
412 if (!bScrollable
) createParams
.Style
|= (int) ListViewFlags
.LVS_NOSCROLL
;
413 if (!bHideSelection
) createParams
.Style
|= (int) ListViewFlags
.LVS_SHOWSELALWAYS
;
417 case ColumnHeaderStyle
.Clickable
: // Default
419 case ColumnHeaderStyle
.Nonclickable
:
420 createParams
.Style
|= (int) ListViewFlags
.LVS_NOSORTHEADER
;
422 case ColumnHeaderStyle
.None
:
423 createParams
.Style
|= (int) ListViewFlags
.LVS_NOCOLUMNHEADER
;
431 case BorderStyle
.Fixed3D
:
432 createParams
.ExStyle
|= (int) WindowExStyles
.WS_EX_CLIENTEDGE
;
434 case BorderStyle
.FixedSingle
:
435 createParams
.Style
|= (int) WindowStyles
.WS_BORDER
;
437 case BorderStyle
.None
:
438 //createParams.ExStyle |= (int) ListViewFlags.LVS_NOCOLUMNHEADER;
448 protected override Size DefaultSize
{
450 return new Size(121, 97); //Correct Size.
455 // --- Protected Methods
459 protected override void CreateHandle() {
464 protected override bool IsInputKey(Keys keyData
) {
466 return base.IsInputKey(keyData
);
471 protected virtual void OnAfterLabelEdit(LabelEditEventArgs e
) {}
472 protected virtual void OnBeforeLabelEdit(LabelEditEventArgs e
) {}
473 protected virtual void OnColumnClick(ColumnClickEventArgs e
) {}
474 protected virtual void OnItemActivate(EventArgs e
) {}
477 protected override void OnEnabledChanged(EventArgs e
) {
479 base.OnEnabledChanged(e
);
483 protected override void OnFontChanged(EventArgs e
) {
485 base.OnFontChanged(e
);
488 protected override void OnHandleCreated(EventArgs e
) {
490 base.OnHandleCreated(e
);
493 protected override void OnHandleDestroyed(EventArgs e
) {
499 protected virtual void OnItemCheck(ItemCheckEventArgs e
) {
503 protected virtual void OnItemDrag(ItemDragEventArgs e
) {
507 // protected virtual void OnSelectedItemChanged(EventArgs e) {
512 protected override void OnSystemColorsChanged(EventArgs e
) {
514 base.OnSystemColorsChanged(e
);
517 protected override void Select(bool directed
, bool forward
) {
519 base.Select(directed
, forward
);
522 protected void UpdateExtendedStyles() {
528 // --- Private Methods
530 private int TextAlign(HorizontalAlignment textAlign
)
535 case HorizontalAlignment
.Left
:
536 style
= (int) ListViewColumnFlags
.LVCFMT_LEFT
;
538 case HorizontalAlignment
.Center
:
539 style
= (int) ListViewColumnFlags
.LVCFMT_CENTER
;
541 case HorizontalAlignment
.Right
:
542 style
= (int) ListViewColumnFlags
.LVCFMT_RIGHT
;
546 throw new InvalidEnumArgumentException(); // TODO: Is this ok?
552 // Converts from SortOrder enumerator to a LVS_ type
553 private int SortMsg(SortOrder sortOrder
) {
559 case SortOrder
.Ascending
:
560 nRslt
= (int) ListViewFlags
.LVS_SORTASCENDING
;
562 case SortOrder
.Descending
:
563 nRslt
= (int) ListViewFlags
.LVS_SORTDESCENDING
;
570 throw new InvalidEnumArgumentException(); // TODO: Is this ok?
573 //Console.WriteLine("Sort value " + nRslt);
577 // Convers from SortOrder enumerator to a LVS_ type
578 private ListViewExtendedFlags
ItemActivationMsg(ItemActivation itemActivation
) {
580 ListViewExtendedFlags nRslt
;
582 switch (itemActivation
)
584 case ItemActivation
.OneClick
:
585 nRslt
= ListViewExtendedFlags
.LVS_EX_ONECLICKACTIVATE
;
587 case ItemActivation
.TwoClick
:
588 nRslt
= ListViewExtendedFlags
.LVS_EX_TWOCLICKACTIVATE
;
590 case ItemActivation
.Standard
:
595 throw new InvalidEnumArgumentException();
602 // Converts from enum View to Win32 LCV_ flag
604 private int ViewMode(View view
)
610 viewCtrl
= (int) ListViewFlags
.LVS_REPORT
;
613 viewCtrl
= (int) ListViewFlags
.LVS_ICON
;
616 viewCtrl
= (int) ListViewFlags
.LVS_LIST
;
619 viewCtrl
= (int) ListViewFlags
.LVS_SMALLICON
;
623 throw new InvalidEnumArgumentException();
629 // Inserts a column in the control
630 internal void InsertColumnInCtrl(ColumnHeader column
)
632 if (!bInitialised
) return;
634 LVCOLUMN lvc
= new LVCOLUMN();
635 bool bAutoSizing
= false;
638 Console
.WriteLine("Insert columns " + column
.Text
+ " pos: " + column
.Index
+ " serial: "+ column
.Serial
+ " autosizing " + bAutoSizing
);
640 lvc
.mask
= (int)( ListViewColumnFlags
.LVCF_FMT
| ListViewColumnFlags
.LVCF_WIDTH
| ListViewColumnFlags
.LVCF_TEXT
| ListViewColumnFlags
.LVCF_SUBITEM
);
641 lvc
.iSubItem
= column
.Serial
;
642 lvc
.pszText
= column
.Text
;
643 lvc
.cx
= column
.Width
;
644 lvc
.fmt
= TextAlign(column
.TextAlign
);
646 IntPtr lvcBuffer
= Marshal
.AllocHGlobal(Marshal
.SizeOf(lvc
));
647 Marshal
.StructureToPtr(lvc
, lvcBuffer
, false);
648 iCol
= (int) Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_INSERTCOLUMNA
, column
.Index
, lvcBuffer
);
649 Marshal
.FreeHGlobal(lvcBuffer
);
652 // Inserts an item in the control
653 internal void InsertItemInCtrl(ListViewItem listViewItem
)
655 if (!bInitialised
) return;
657 LVITEM item
= new LVITEM();
659 item
.pszText
= listViewItem
.Text
;
660 item
.iItem
= listViewItem
.Index
;
663 item
.mask
= ListViewItemFlags
.LVIF_TEXT
;
665 IntPtr liBuffer
= Marshal
.AllocHGlobal(Marshal
.SizeOf(item
));
666 Marshal
.StructureToPtr(item
, liBuffer
, false);
667 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_INSERTITEMA
, listViewItem
.Index
, liBuffer
);
668 Marshal
.FreeHGlobal(liBuffer
);
670 Console
.WriteLine("Inserting " + listViewItem
.Index
+ "-" + listViewItem
.Text
);
673 // Removes an item in the control
674 internal void RemoveItemInCtrl(int iIndex
)
676 if (!bInitialised
) return;
677 Console
.WriteLine("Deleting " + iIndex
);
678 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_DELETEITEM
, iIndex
, 0);
683 internal Rectangle
GetItemBoundInCtrl(int iIndex
)
685 if (!bInitialised
) return new Rectangle();
687 IntPtr lpBuffer
= IntPtr
.Zero
;
690 RECT rect
= new RECT();
691 rect
.left
= (int) SubItemPortion
.LVIR_BOUNDS
;
692 lpBuffer
= Marshal
.AllocHGlobal(Marshal
.SizeOf(rect
));
693 Marshal
.StructureToPtr(rect
, lpBuffer
, false);
694 Win32
.SendMessage (Handle
, (int) ListViewMessages
.LVM_GETITEMRECT
, iIndex
, lpBuffer
);
696 rect
= (RECT
) Marshal
.PtrToStructure (lpBuffer
, typeof (RECT
));
697 return new Rectangle (rect
.left
, rect
.top
, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
700 Marshal
.FreeHGlobal (lpBuffer
);
705 internal void LabelEditInCtrl(int iIndex
)
707 if (!bInitialised
) return;
709 Win32
.SetFocus(Handle
); // Need focus first
710 Win32
.SendMessage (Handle
, (int) ListViewMessages
.LVM_EDITLABEL
, iIndex
, 0);
715 internal void SetItemInCtrl(ListViewItem
.ListViewSubItem listViewSubItem
, int nPos
)
717 if (!bInitialised
) return;
719 LVITEM item
= new LVITEM();
721 item
.pszText
= listViewSubItem
.Text
;
722 item
.iItem
= listViewSubItem
.ListViewItem
.Index
;
723 item
.iSubItem
= nPos
;
725 item
.mask
= ListViewItemFlags
.LVIF_TEXT
;
727 Console
.WriteLine("SetItemInCtrl " + nPos
);
729 IntPtr liBuffer
= Marshal
.AllocHGlobal(Marshal
.SizeOf(item
));
730 Marshal
.StructureToPtr(item
, liBuffer
, false);
731 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETITEMA
, 0, liBuffer
);
732 Marshal
.FreeHGlobal(liBuffer
);
737 // Remove a column from the control
738 internal int DeleteColumnInCtrl(int nIndex
){
740 if (!bInitialised
) return 0;
742 Console
.WriteLine("Delete column " + nIndex
);
743 return Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_DELETECOLUMN
, nIndex
, 0);
746 // Get the check status of an item
747 internal bool GetCheckStateInCtrl(int nIndex
){
749 if (!bInitialised
) return false;
751 if ((Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_GETITEMSTATE
, nIndex
,
752 (int)ListViewItemState
.LVIS_STATEIMAGEMASK
) & (int)ListViewItemState
.LVIS_CHECKED
)==(int)ListViewItemState
.LVIS_CHECKED
)
759 // Sets item activation
760 internal void ItemActivationCtrl(){
762 ListViewExtendedFlags flags
= ItemActivationMsg(Activation
); // Thowns an exception
764 if (!bInitialised
) return;
766 if (flags
==0) // Standard mode
768 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETEXTENDEDLISTVIEWSTYLE
, (int)ListViewExtendedFlags
.LVS_EX_ONECLICKACTIVATE
, 0);
769 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETEXTENDEDLISTVIEWSTYLE
, (int)ListViewExtendedFlags
.LVS_EX_TWOCLICKACTIVATE
, 0);
772 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETEXTENDEDLISTVIEWSTYLE
, (int)flags
, (int)flags
);
775 // Sets or remove and extended style from the control
776 internal void ExtendedStyleCtrl(ListViewExtendedFlags ExStyle
, bool bStatus
){
778 if (!bInitialised
) return;
781 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETEXTENDEDLISTVIEWSTYLE
, (int)ExStyle
, (int)ExStyle
);
783 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETEXTENDEDLISTVIEWSTYLE
, (int)ExStyle
, 0);
787 // Sets Background color in control
788 internal void SetBkColorCtrl(){
790 if (!bInitialised
) return;
791 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETBKCOLOR
, 0, (int) (backColor
.R
| backColor
.G
<<8 | backColor
.B
<<16));
794 // Sets Background color in an item
795 internal void SetItemBkColorCtrl(Color col
){
797 if (!bInitialised
) return;
798 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETTEXTBKCOLOR
, 0, (int) (col
.R
| col
.G
<<8 | col
.B
<<16));
801 internal void insertItemsInCtrl() {
803 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_DELETEALLITEMS
, 0,0);
804 Win32
.SendMessage(Handle
, (int)Msg
.WM_SETREDRAW
, 0,0);
805 for (int i
=0; i
<Items
.Count
; i
++){ // Insert items
807 InsertItemInCtrl(Items
[i
]);
809 for (int s
=0; s
<Items
[i
].SubItems
.Count
; s
++) // Insert subitems
810 SetItemInCtrl(Items
[i
].SubItems
[s
], s
+1);
813 Win32
.SendMessage(Handle
, (int)Msg
.WM_SETREDRAW
, 1,0);
817 protected override void WndProc(ref Message m
) {
823 if (bAllowColumnReorder
) ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_HEADERDRAGDROP
, bAllowColumnReorder
);
824 if (bFullRowSelect
) ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_FULLROWSELECT
, bFullRowSelect
);
825 if (bGridLines
) ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_GRIDLINES
, bGridLines
);
826 if (bCheckBoxes
) ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_CHECKBOXES
, bCheckBoxes
);
827 if (bHoverSelection
) ExtendedStyleCtrl(ListViewExtendedFlags
.LVS_EX_TRACKSELECT
, bHoverSelection
);
830 ItemActivationCtrl();
832 for (int i
=0; i
<Columns
.Count
; i
++) // Insert columns
833 InsertColumnInCtrl(Columns
[i
]);
837 // We need to setup the column autoresizing flags after all the columns and items
839 for (int i
=0; i
<Columns
.Count
; i
++) {
841 if (Columns
[i
].Width
!=-1 && Columns
[i
].Width
!=-2) continue;
843 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_SETCOLUMNWIDTH
, Columns
[i
].Index
,
849 if (m
.Msg
== (int) Msg
.WM_NOTIFY
)
851 NMHDR nmhdr
= (NMHDR
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMHDR
));
853 m
.Result
= IntPtr
.Zero
;
855 //Console.WriteLine("Notify->" + m);
857 switch (nmhdr
.code
) {
858 case (int)ListViewNotifyMsg
.LVN_COLUMNCLICK
:
860 NMLISTVIEW NmLstView
= (NMLISTVIEW
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMLISTVIEW
));
862 // Get get the index of the visual order, we have to we get the column unique ID to get its object
863 LVCOLUMN lvc
= new LVCOLUMN();
864 lvc
.mask
= (int) ListViewColumnFlags
.LVCF_SUBITEM
;
866 IntPtr lvcBuffer
= Marshal
.AllocHGlobal(Marshal
.SizeOf(lvc
));
867 Marshal
.StructureToPtr(lvc
, lvcBuffer
, false);
868 Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_GETCOLUMNA
, NmLstView
.iSubItem
, lvcBuffer
);
869 lvc
= (LVCOLUMN
) Marshal
.PtrToStructure(lvcBuffer
, typeof(LVCOLUMN
));
871 ColumnHeader col
= Columns
.FromSerial(lvc
.iSubItem
);
872 ColumnClickEventArgs eventArg
= new ColumnClickEventArgs(col
.Index
);
873 OnColumnClick(eventArg
);
875 Marshal
.FreeHGlobal(lvcBuffer
);
879 case (int)ListViewNotifyMsg
.LVN_BEGINLABELEDITA
:
881 Console
.WriteLine("ListViewMessages.LVN_BEGINLABELEDITA");
883 LVDISPINFO lvDispInfo
= (LVDISPINFO
)Marshal
.PtrToStructure (m
.LParam
, typeof (LVDISPINFO
));
884 LabelEditEventArgs editEvent
= new LabelEditEventArgs(lvDispInfo
.item
.iItem
);
885 editEvent
.CancelEdit
= false;
887 OnBeforeLabelEdit(editEvent
);
889 if (editEvent
.CancelEdit
)
890 m
.Result
= (System
.IntPtr
)1;
892 m
.Result
= (System
.IntPtr
)0;
898 case (int)ListViewNotifyMsg
.LVN_ENDLABELEDITA
:
900 Console
.WriteLine("ListViewMessages.LVN_ENDLABELEDITA");
902 LVDISPINFO lvDispInfo
= (LVDISPINFO
)Marshal
.PtrToStructure (m
.LParam
, typeof (LVDISPINFO
));
903 LabelEditEventArgs editEvent
= new LabelEditEventArgs(lvDispInfo
.item
.iItem
, lvDispInfo
.item
.pszText
);
904 editEvent
.CancelEdit
= false;
906 OnAfterLabelEdit(editEvent
);
908 if (editEvent
.CancelEdit
)
909 m
.Result
= (System
.IntPtr
)0;
911 m
.Result
= (System
.IntPtr
)1;
916 case (int)ListViewNotifyMsg
.LVN_ITEMACTIVATE
:
918 //NMITEMACTIVATE is used instead of NMLISTVIEW in IE >= 0x400
919 NMITEMACTIVATE NmItemAct
= (NMITEMACTIVATE
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMITEMACTIVATE
));
921 Console
.WriteLine("ListViewMessages.LVN_ITEMACTIVATE " + NmItemAct
.iItem
+ "sub: " + NmItemAct
.iSubItem
);
923 OnItemActivate(new EventArgs());
928 case (int)ListViewNotifyMsg
.LVN_ITEMCHANGED
:
931 NMLISTVIEW NmLstView
= (NMLISTVIEW
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMLISTVIEW
));
933 Console
.WriteLine("ListViewMessages.LVN_ITEMCHANGED item:" + NmLstView
.iItem
+ " sub: "+ NmLstView
.iSubItem
+ "att:" +NmLstView
.uChanged
);
935 // NOTE: Using the LVIS_SELECTED status does not work well when you use the control
936 // to select diferent items.
940 for (int i
=0; i
< selItemIndexs
.Count
; i
++)
941 Items
[selItemIndexs
[i
]].Selected
=false;
943 int nItem
= Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_GETNEXTITEM
, -1, (int) ListViewNotifyItem
.LVNI_SELECTED
);
947 selItemsCol
.Add(nItem
);
948 Items
[nItem
].Selected
=true;
949 nItem
= Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_GETNEXTITEM
, nItem
, (int) ListViewNotifyItem
.LVNI_SELECTED
);
952 // Check checked items
953 int nItems
= Win32
.SendMessage(Handle
, (int)ListViewMessages
.LVM_GETITEMCOUNT
, 0, 0);
956 for (int i
=0; i
< chkItemCol
.Count
; i
++)
957 Items
[i
].Checked
= false;
959 for (int i
=0; i
<nItems
; i
++){
960 if (GetCheckStateInCtrl(i
)) {
962 Items
[i
].Checked
= true;
969 // Note: Under WinXP we get HDN_ITEMCHANGEDW
970 // seems that we change this using LVM_SETUNICODEFORMAT
971 case (int)HeaderCtrlNOtify
.HDN_ITEMCHANGEDA
:
972 case (int)HeaderCtrlNOtify
.HDN_ITEMCHANGEDW
:
975 NMHEADER NmHeader
= (NMHEADER
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMHEADER
));
976 HDITEM HDItem
= (HDITEM
)Marshal
.PtrToStructure(NmHeader
.pitem
, typeof (HDITEM
));
978 if (((uint)HDItem
.mask
& (uint)HeaderItemFlags
.HDI_HEIGHT
)==(uint)HeaderItemFlags
.HDI_HEIGHT
)
980 Console
.WriteLine("HDN_ITEMCHANGED item:" + NmHeader
.iItem
+ " width: " +HDItem
.cxy
);
981 Columns
[NmHeader
.iItem
].Width
= HDItem
.cxy
;
988 // Used to paint item colours and font
989 case (int)NotificationMessages
.NM_CUSTOMDRAW
:
992 NMLVCUSTOMDRAW LVNmCustom
= (NMLVCUSTOMDRAW
)Marshal
.PtrToStructure (m
.LParam
, typeof (NMLVCUSTOMDRAW
));
994 switch(LVNmCustom
.nmcd
.dwDrawStage
) {
997 case (int)CustomDrawDrawStateFlags
.CDDS_PREPAINT
:
998 m
.Result
= (IntPtr
)CustomDrawReturnFlags
.CDRF_NOTIFYITEMDRAW
;
1001 case (int)CustomDrawDrawStateFlags
.CDDS_ITEMPREPAINT
:
1003 if (Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
].UseItemStyleForSubItems
) {
1005 LVNmCustom
.clrTextBk
= (uint) Win32
.RGB (Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
].BackColor
);
1006 LVNmCustom
.clrText
= (uint) Win32
.RGB (Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
].ForeColor
);
1007 Marshal
.StructureToPtr(LVNmCustom
, m
.LParam
, false);
1008 m
.Result
=(IntPtr
)CustomDrawReturnFlags
.CDRF_NEWFONT
;
1011 m
.Result
=(IntPtr
)CustomDrawReturnFlags
.CDRF_NOTIFYSUBITEMDRAW
;
1015 case (int)(CustomDrawDrawStateFlags
.CDDS_SUBITEM
| CustomDrawDrawStateFlags
.CDDS_ITEMPREPAINT
):
1017 ListViewItem item
= Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
];
1020 if (LVNmCustom
.iSubItem
==0) {
1021 LVNmCustom
.clrTextBk
= (uint) Win32
.RGB (Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
].BackColor
);
1022 LVNmCustom
.clrText
= (uint) Win32
.RGB (Items
[(int)LVNmCustom
.nmcd
.dwItemSpec
].ForeColor
);
1023 Marshal
.StructureToPtr(LVNmCustom
, m
.LParam
, false);
1024 m
.Result
=(IntPtr
)CustomDrawReturnFlags
.CDRF_NEWFONT
;
1028 ListViewItem
.ListViewSubItem subItem
;
1029 int nIdx
= (int) LVNmCustom
.iSubItem
-1;
1031 // We get an event by column even if the item is not inseted
1032 if (nIdx
<item
.SubItems
.Count
){
1033 subItem
= item
.SubItems
[nIdx
];
1034 LVNmCustom
.clrTextBk
= (uint) Win32
.RGB (subItem
.BackColor
);
1035 LVNmCustom
.clrText
= (uint) Win32
.RGB (subItem
.ForeColor
);
1036 Marshal
.StructureToPtr(LVNmCustom
, m
.LParam
, false);
1037 m
.Result
=(IntPtr
)CustomDrawReturnFlags
.CDRF_NEWFONT
;
1056 CallControlWndProc (ref m
);
1061 // System.Windows.Forms.ListView.SelectedListViewItemCollection.cs
1064 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1065 // implemented by Jordi Mas i Hernàndez <jmas@softcatala.org>
1067 // It has been implemented really as an array of indexes of ListViewItemCollection
1068 // to avoid information and item duplication in memory / Jordi
1070 // (C) 2002-3 Ximian, Inc
1075 public class SelectedListViewItemCollection
: IList
, ICollection
, IEnumerable
{
1077 private ListView container
= null;
1078 private ArrayList collection
= new ArrayList();
1083 public SelectedListViewItemCollection(ListView owner
) {
1088 // --- Public Properties
1091 get { return collection.Count; }
1093 public bool IsReadOnly
{
1094 get { return collection.IsReadOnly; }
1097 public ListViewItem
this[int index
] {
1100 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1101 return container
.Items
[(int)collection
[index
]];
1104 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1105 collection
[index
] = value.Index
;}
1109 // --- Internal Methods for the implementation
1111 internal void Add (int nIndex
) {
1112 collection
.Add(nIndex
);
1115 internal void Remove (int nIndex
) {
1116 collection
.Remove(nIndex
);
1120 // --- Public Methods
1123 public void Clear() {
1127 public bool Contains(ListViewItem item
) {
1128 return collection
.Contains(item
);
1131 public void CopyTo(Array dest
, int index
) {
1132 collection
.CopyTo(dest
, index
);
1135 public override bool Equals(object obj
) {
1136 return collection
.Equals(obj
);
1140 public override int GetHashCode() {
1141 //FIXME add our proprities
1142 return base.GetHashCode();
1145 public IEnumerator
GetEnumerator() {
1146 return collection
.GetEnumerator();
1149 public int IndexOf(ListViewItem item
) {
1150 return collection
.IndexOf(item
);
1153 /// IList Interface implmentation.
1155 bool IList
.IsReadOnly
{
1156 get{return collection.IsReadOnly;}
1158 bool IList
.IsFixedSize
{
1159 get{return collection.IsFixedSize;}
1163 object IList
.this[int index
]{
1164 get { return collection[index]; }
1165 set { collection[index] = value; }
1173 int IList
.Add( object value){
1174 return collection
.Add(value);
1178 bool IList
.Contains( object value){
1179 return collection
.Contains(value);
1183 int IList
.IndexOf( object value){
1184 return collection
.IndexOf(value);
1188 void IList
.Insert(int index
, object value){
1189 collection
.Insert(index
, value);
1193 void IList
.Remove( object value){
1194 collection
.Remove(value);
1198 void IList
.RemoveAt( int index
){
1199 collection
.RemoveAt(index
);
1201 // End of IList interface
1203 /// ICollection Interface implmentation.
1205 int ICollection
.Count
{
1207 throw new NotImplementedException ();
1210 bool ICollection
.IsSynchronized
{
1212 throw new NotImplementedException ();
1215 object ICollection
.SyncRoot
{
1217 throw new NotImplementedException ();
1220 void ICollection
.CopyTo(Array array
, int index
){
1223 // End Of ICollection
1226 // System.Windows.Forms.ListView.CheckedListViewItemCollection.cs
1229 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1230 // implemented by Jordi Mas i Hernàndez <jmas@softcatala.org>
1232 // It has been implemented really as an array of indexes of ListViewItemCollection
1233 // to avoid information and item duplication in memory / Jordi
1234 // (C) 2002-3 Ximian, Inc
1239 public class CheckedListViewItemCollection
: IList
, ICollection
, IEnumerable
{
1241 private ListView container
= null;
1242 private ArrayList collection
= new ArrayList();
1247 public CheckedListViewItemCollection(ListView owner
) {
1252 // --- Public Properties
1255 get { return collection.Count; }
1258 public bool IsReadOnly
{
1262 public virtual ListViewItem
this[int index
] {
1264 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1265 return container
.Items
[(int)collection
[index
]];
1268 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1269 collection
[index
] = value.Index
;
1274 // --- Internal Methods for the implementation
1276 internal void Clear() {
1280 internal void Add (int nIndex
) {
1281 collection
.Add(nIndex
);
1286 // --- Public Methods
1288 public bool Contains(ListViewItem item
) {
1289 return collection
.Contains(item
);
1293 public object CopyTo(Array dest
, int index
) {
1294 throw new NotImplementedException ();
1297 public override bool Equals(object obj
) {
1298 return collection
.Equals(obj
);
1301 public override int GetHashCode() {
1302 //FIXME add our proprities
1303 return base.GetHashCode();
1306 public IEnumerator
GetEnumerator() {
1307 return collection
.GetEnumerator();
1310 public int IndexOf(ListViewItem item
) {
1311 return collection
.IndexOf(item
);
1314 /// IList Interface implementation.
1316 bool IList
.IsReadOnly
{
1319 bool IList
.IsFixedSize
{
1324 object IList
.this[int index
]{
1326 throw new NotImplementedException ();
1339 int IList
.Add( object value){
1340 throw new NotImplementedException ();
1344 bool IList
.Contains( object value){
1345 throw new NotImplementedException ();
1349 int IList
.IndexOf( object value){
1350 return collection
.IndexOf(value);
1354 void IList
.Insert(int index
, object value){
1359 void IList
.Remove( object value){
1364 void IList
.RemoveAt( int index
){
1367 // End of IList interface
1369 /// ICollection Interface implmentation.
1371 int ICollection
.Count
{
1373 throw new NotImplementedException ();
1376 bool ICollection
.IsSynchronized
{
1378 throw new NotImplementedException ();
1381 object ICollection
.SyncRoot
{
1383 throw new NotImplementedException ();
1386 void ICollection
.CopyTo(Array array
, int index
){
1389 // End Of ICollection
1392 // System.Windows.Forms.ListView.ColumnHeaderCollection.cs
1395 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1396 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
1398 // (C) 2002-3 Ximian, Inc
1402 public class ColumnHeaderCollection
: IList
, ICollection
, IEnumerable
1404 private ListView container
= null;
1405 private ArrayList collection
= new ArrayList();
1406 private int nUniqueSerial
= 5000;
1411 public ColumnHeaderCollection(ListView owner
) {
1416 // --- Public Properties
1419 get { return collection.Count; }
1422 public bool IsReadOnly
{
1423 get { return collection.IsReadOnly; }
1426 public virtual ColumnHeader
this[int index
] {
1428 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1429 return (ColumnHeader
) collection
[index
];
1432 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1433 collection
[index
] = value;
1438 // --- Private methods used by the implementation
1440 public ColumnHeader
FromSerial(int nSerial
)
1442 for (int i
=0; i
< collection
.Count
; i
++){
1443 ColumnHeader col
= (ColumnHeader
)collection
[i
];
1444 if (col
.Serial
==nSerial
) return col
;
1450 // The indexes have to be re-calculated
1451 public void ReIndexCollection() {
1452 for (int i
=0; i
< collection
.Count
; i
++)
1454 ColumnHeader col
= (ColumnHeader
)collection
[i
];
1457 container
.insertItemsInCtrl();
1461 // --- Public Methods
1464 public virtual int Add(ColumnHeader column
) {
1466 column
.Serial
= nUniqueSerial
;
1467 column
.CtrlIndex
= Count
;
1468 collection
.Add(column
);
1471 container
.InsertColumnInCtrl(column
);
1475 public virtual ColumnHeader
Add(string s
, int witdh
, HorizontalAlignment align
) {
1477 ColumnHeader column
= new ColumnHeader();
1479 /* The zero-based index of the column header within the ListView.ColumnHeaderCollection of the ListView control it is contained in.*/
1480 column
.CtrlIndex
= Count
;
1482 column
.TextAlign
= align
;
1483 column
.Width
= witdh
;
1484 column
.Container
= container
;
1485 column
.Serial
= nUniqueSerial
;
1486 collection
.Add(column
);
1488 container
.InsertColumnInCtrl(column
);
1493 public virtual void AddRange(ColumnHeader
[] values
) {
1494 for (int i
=0; i
<values
.Length
; i
++) {
1499 public void Clear() {
1501 // Delete all columns
1503 for (int n
=0; nRslt
!=0; n
++)
1504 nRslt
= container
.DeleteColumnInCtrl(0);
1509 public bool Contains(ColumnHeader
value) {
1510 return collection
.Contains(value);
1513 public override bool Equals(object obj
) {
1515 if(obj
!= null && obj
is ColumnHeaderCollection
) {
1516 ColumnHeaderCollection that
= (ColumnHeaderCollection
)obj
;
1517 return (this.collection
== that
.collection
);
1524 public override int GetHashCode()
1526 //FIXME add our proprities
1527 return base.GetHashCode();
1530 public IEnumerator
GetEnumerator(){
1531 return collection
.GetEnumerator();
1534 public int IndexOf(ColumnHeader
value) {
1535 return collection
.IndexOf(value);
1538 public void Insert(int index
, ColumnHeader column
) {
1540 column
.Serial
= nUniqueSerial
;
1541 column
.CtrlIndex
= index
;
1542 collection
.Insert(index
, column
);
1544 container
.InsertColumnInCtrl(column
);
1545 ReIndexCollection();
1548 public void Insert(int index
, string str
, int witdh
, HorizontalAlignment align
) {
1550 ColumnHeader column
= new ColumnHeader();
1553 column
.TextAlign
= align
;
1554 column
.Width
= witdh
;
1555 column
.Container
= container
;
1556 Insert(index
, column
);
1560 public virtual void Remove(ColumnHeader
value) {
1561 RemoveAt(value.Index
);
1565 public virtual void RemoveAt(int index
)
1568 throw new ArgumentOutOfRangeException("Invalid value for array index");
1570 container
.DeleteColumnInCtrl(index
);
1571 collection
.Remove(collection
[index
]);
1573 ReIndexCollection();
1577 /// IList Interface implmentation.
1579 bool IList
.IsReadOnly
{
1581 // We allow addition, removeal, and editing of items after creation of the list.
1585 bool IList
.IsFixedSize
{
1587 // We allow addition and removeal of items after creation of the list.
1592 object IList
.this[int index
]{
1593 [MonoTODO
] get { throw new NotImplementedException (); }
1594 [MonoTODO
] set { throw new NotImplementedException (); }
1603 int IList
.Add( object value){
1604 throw new NotImplementedException ();
1608 bool IList
.Contains( object value){
1609 throw new NotImplementedException ();
1613 int IList
.IndexOf( object value){
1614 return collection
.IndexOf(value);
1618 void IList
.Insert(int index
, object value){
1623 void IList
.Remove( object value){
1628 void IList
.RemoveAt( int index
){
1631 // End of IList interface
1633 /// ICollection Interface implmentation.
1635 int ICollection
.Count
{
1637 throw new NotImplementedException ();
1640 bool ICollection
.IsSynchronized
{
1642 throw new NotImplementedException ();
1645 object ICollection
.SyncRoot
{
1647 throw new NotImplementedException ();
1650 void ICollection
.CopyTo(Array array
, int index
){
1653 // End Of ICollection
1658 // System.Windows.Forms.ListView.ListViewItemCollection.cs
1661 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1662 // Implemented by Jordi i Hernàndez (jmas@softcatala.org)
1664 // (C) 2002/3 Ximian, Inc
1669 public class ListViewItemCollection
: IList
, ICollection
, IEnumerable
1671 private ListView container
= null;
1672 private ArrayList collection
= new ArrayList();
1677 public ListViewItemCollection (ListView owner
) {
1682 // --- Public Properties
1685 get { return collection.Count; }
1688 public bool IsReadOnly
{
1689 get { return collection.IsReadOnly; }
1692 public virtual ListViewItem
this [int index
] {
1695 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1696 return (ListViewItem
) collection
[index
];
1699 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1700 collection
[index
] = value;
1705 // --- Public Methods
1707 public virtual ListViewItem
Add (ListViewItem item
) {
1709 Console
.WriteLine("ListViewItem.Add " + item
.Text
+ " idx: " + item
.Index
);
1711 item
.CtrlIndex
= Count
;
1712 item
.Container
= container
;
1713 container
.InsertItemInCtrl(item
);
1714 int nIdx
= collection
.Add(item
);
1715 return (ListViewItem
)collection
[nIdx
];
1719 public virtual ListViewItem
Add (string str
) {
1720 throw new NotImplementedException ();
1723 public virtual ListViewItem
Add (string str
, int val
) {
1724 throw new NotImplementedException ();
1727 public void AddRange(ListViewItem
[] values
) {
1729 for (int i
=0; i
<values
.Length
; i
++)
1731 container
.InsertItemInCtrl(values
[i
]);
1737 public void Clear() {
1741 public bool Contains(ListViewItem item
) {
1742 throw new NotImplementedException ();
1745 public void CopyTo(Array dest
, int index
) {
1749 public override bool Equals(object obj
) {
1751 return base.Equals(obj
);
1755 public override int GetHashCode() {
1756 //FIXME add our proprities
1757 return base.GetHashCode();
1760 public IEnumerator
GetEnumerator() {
1761 return collection
.GetEnumerator();
1764 public int IndexOf(ListViewItem item
) {
1765 return collection
.IndexOf(item
);
1768 public virtual void Remove(ListViewItem item
) {
1772 public virtual void RemoveAt(int index
) {
1775 throw new ArgumentOutOfRangeException("Invalid value for array index");
1777 container
.RemoveItemInCtrl(index
);
1778 collection
.Remove(collection
[index
]);
1780 // The indexes have to be re-calculated
1781 for (int i
=0; i
< collection
.Count
; i
++)
1783 ListViewItem item
= (ListViewItem
)collection
[i
];
1787 // Todo: Invalidate selection since indexes have changed
1791 /// IList Interface implmentation.
1793 bool IList
.IsReadOnly
{
1795 // We allow addition, removeal, and editing of items after creation of the list.
1799 bool IList
.IsFixedSize
{
1801 // We allow addition and removeal of items after creation of the list.
1807 object IList
.this[int index
]{
1809 throw new NotImplementedException ();
1822 int IList
.Add( object value){
1823 throw new NotImplementedException ();
1827 bool IList
.Contains( object value){
1828 throw new NotImplementedException ();
1832 int IList
.IndexOf( object value){
1833 return collection
.IndexOf(value);
1837 void IList
.Insert(int index
, object value){
1842 void IList
.Remove( object value){
1847 void IList
.RemoveAt( int index
){
1850 // End of IList interface
1852 /// ICollection Interface implmentation.
1854 int ICollection
.Count
{
1856 throw new NotImplementedException ();
1859 bool ICollection
.IsSynchronized
{
1861 throw new NotImplementedException ();
1864 object ICollection
.SyncRoot
{
1866 throw new NotImplementedException ();
1869 void ICollection
.CopyTo(Array array
, int index
){
1872 // End Of ICollection
1875 // System.Windows.Forms.ListView.SelectedIndexCollection.cs
1878 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1879 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
1881 // Implemented as a wrapper to SelectedListViewItemCollection
1883 // (C) 2002-3 Ximian, Inc
1889 public class SelectedIndexCollection
: IList
, ICollection
, IEnumerable
{
1891 private ListView container
= null;
1896 public SelectedIndexCollection(ListView owner
) {
1901 // --- Public Properties
1904 get { return container.SelectedItems.Count; }
1907 public bool IsReadOnly
{
1908 get { return container.SelectedItems.IsReadOnly; }
1912 public int this [int index
] {
1914 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
1915 return container
.SelectedItems
[index
].Index
;
1920 // --- Public Methods
1923 public bool Contains(ListView item
) {
1924 throw new NotImplementedException ();
1927 public void CopyTo(Array dest
, int index
) {
1931 public override bool Equals(object obj
) {
1933 return base.Equals(obj
);
1936 public override int GetHashCode() {
1937 //FIXME add our proprities
1938 return base.GetHashCode();
1941 public IEnumerator
GetEnumerator() {
1942 throw new NotImplementedException ();
1945 public int IndexOf(int index
) {
1946 throw new NotImplementedException ();
1949 /// IList Interface implmentation.
1951 bool IList
.IsReadOnly
{
1953 // We allow addition, removeal, and editing of items after creation of the list.
1957 bool IList
.IsFixedSize
{
1959 // We allow addition and removeal of items after creation of the list.
1964 object IList
.this[int index
]{
1965 [MonoTODO
] get { throw new NotImplementedException (); }
1966 [MonoTODO
] set { throw new NotImplementedException (); }
1975 int IList
.Add( object value){
1976 throw new NotImplementedException ();
1980 bool IList
.Contains( object value){
1981 throw new NotImplementedException ();
1985 int IList
.IndexOf( object value){
1986 throw new NotImplementedException ();
1990 void IList
.Insert(int index
, object value){
1995 void IList
.Remove( object value){
1996 throw new NotImplementedException ();
2000 void IList
.RemoveAt( int index
){
2003 // End of IList interface
2005 /// ICollection Interface implmentation.
2007 int ICollection
.Count
{
2009 throw new NotImplementedException ();
2012 bool ICollection
.IsSynchronized
{
2014 throw new NotImplementedException ();
2017 object ICollection
.SyncRoot
{
2019 throw new NotImplementedException ();
2022 void ICollection
.CopyTo(Array array
, int index
){
2023 throw new NotImplementedException ();
2025 // End Of ICollection
2028 // System.Windows.Forms.ListView.CheckedIndexCollection.cs
2031 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
2032 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
2034 // (C) 2002-3 Ximian, Inc
2038 public class CheckedIndexCollection
: IList
, ICollection
, IEnumerable
{
2040 private ListView container
= null;
2045 public CheckedIndexCollection(ListView owner
) {
2050 // --- Public Properties
2053 get{return container.CheckedItems.Count;}
2056 public bool IsReadOnly
{
2057 get {return container.CheckedItems.IsReadOnly;}
2060 public int this[int index
] {
2062 if (index
<0 || index
>=Count
) throw new ArgumentOutOfRangeException();
2063 return container
.CheckedItems
[index
].Index
;
2068 // --- Public Methods
2070 public bool Contains(int checkedIndex
) {
2071 throw new NotImplementedException ();
2074 public override bool Equals(object obj
) {
2076 return base.Equals(obj
);
2079 public override int GetHashCode() {
2080 //FIXME add our proprities
2081 return base.GetHashCode();
2084 public IEnumerator
GetEnumerator() {
2085 throw new NotImplementedException ();
2088 public int IndexOf(int checkedIndex
) {
2089 throw new NotImplementedException ();
2092 /// IList Interface implmentation.
2094 bool IList
.IsReadOnly
{
2096 // We allow addition, removeal, and editing of items after creation of the list.
2100 bool IList
.IsFixedSize
{
2102 // We allow addition and removeal of items after creation of the list.
2108 object IList
.this[int index
]{
2110 throw new NotImplementedException ();
2123 int IList
.Add( object value){
2124 throw new NotImplementedException ();
2128 bool IList
.Contains( object value){
2129 throw new NotImplementedException ();
2133 int IList
.IndexOf( object value){
2134 throw new NotImplementedException ();
2138 void IList
.Insert(int index
, object value){
2143 void IList
.Remove( object value){
2144 throw new NotImplementedException ();
2148 void IList
.RemoveAt( int index
){
2149 throw new NotImplementedException ();
2151 // End of IList interface
2153 /// ICollection Interface implmentation.
2155 int ICollection
.Count
{
2157 throw new NotImplementedException ();
2160 bool ICollection
.IsSynchronized
{
2162 throw new NotImplementedException ();
2165 object ICollection
.SyncRoot
{
2167 throw new NotImplementedException ();
2170 void ICollection
.CopyTo(Array array
, int index
){
2173 // End Of ICollection
2175 //***********************************
2177 //***********************************
2179 // // FIXME this sub class has many members that have not been stubbed out.
2180 // public class CheckedListViewItemCollection {
2181 // CheckedListViewItemCollection(ListView owner){
2182 // throw new NotImplementedException ();
2186 // // FIXME this sub class has many members that have not been stubbed out.
2187 // public class ColumnHeaderCollection {
2188 // ColumnHeaderCollection(ListView owner){
2189 // throw new NotImplementedException ();