Browse Source

item color, properties, and fixes

svn path=/trunk/mcs/; revision=18917
Jordi Mas i Hernandez 22 years ago
parent
commit
dcc12e8b2b

+ 130 - 19
mcs/class/System.Windows.Forms/System.Windows.Forms.Test/ListViewItemSimpleForm1.cs

@@ -31,9 +31,34 @@ public class MyListViewForm : System.Windows.Forms.Form
 	// Clear all columns
 	public void ClearColumnsButton()
 	{
+		
 		listViewCtrl.Columns.Clear();
 	}
 	
+	public void	ItemPropButton()
+	{
+		
+		//IList lst = (IList) listViewCtrl.CheckedItems;		
+		
+		Console.WriteLine ("MyListViewForm.ItemPropButton");				
+				
+		string sText = "Item properties---------------\n";
+		
+		for (int i=0; i < listViewCtrl.Items.Count; i++)
+			sText+=("Item->" +  listViewCtrl.Items[i].Text + " idx: " + listViewCtrl.Items[i].Index + 
+			 " Backcolor: "+  listViewCtrl.Items[i].BackColor + " Selected: " +  listViewCtrl.Items[i].Selected +
+			 " Checked: "  +  listViewCtrl.Items[i].Checked + " Focused: " + listViewCtrl.Items[i].Focused +
+			"\n");
+			
+		MessageBox.Show(sText);		
+		
+	}
+	
+	public void CheckedItemButton()
+	{
+		listViewCtrl.CheckBoxes = !listViewCtrl.CheckBoxes;
+	}
+	
 	public void ShowColumnsButton()
 	{
 		string sTxt = "";
@@ -81,19 +106,28 @@ public class MyListViewForm : System.Windows.Forms.Form
 		listViewCtrl.Columns.RemoveAt(1); /*Base on 0 index*/		
 	}
 	
+	// Show selected items
 	public void DumpSelButton()
 	{				
-		// Show selected items
+		
 		if (sel==null)
-		{
-			Console.WriteLine ("Col init");
 			sel = listViewCtrl.SelectedItems;
-		}
 		
-		Console.WriteLine ("Selected---------------");
+		string	sText;				
+		
+		if (sel==null)
+			sel = listViewCtrl.SelectedItems;
+				
+		sText = "Selected---------------\n";
 		
 		for (int i=0; i < sel.Count; i++)
-			Console.WriteLine ("Item->" +  sel[i].Text + " idx: " + sel[i].Index);
+			sText+=("Item->" +  sel[i].Text + " idx: " + sel[i].Index + "\n");
+			
+		sText+= "Checked Items---------------\n";
+		for (int i=0; i < listViewCtrl.CheckedItems.Count; i++)
+			sText+=("Item->" +  listViewCtrl.CheckedItems[i].Text + " idx: " + listViewCtrl.CheckedItems[i].Index + "\n");
+		
+		MessageBox.Show(sText);
 		
 		
 	}
@@ -114,7 +148,8 @@ public class MyListViewForm : System.Windows.Forms.Form
 	
 	public void ShowClassDefaults()
 	{
-	
+		
+		Console.WriteLine ("ListView defaults----");
 		Console.WriteLine ("Sorting " + listViewCtrl.Sorting);
 		Console.WriteLine ("Label Edit " + listViewCtrl.LabelEdit);
 		Console.WriteLine ("FullRowSelect " + listViewCtrl.FullRowSelect);
@@ -126,8 +161,15 @@ public class MyListViewForm : System.Windows.Forms.Form
 		Console.WriteLine ("BackColor " + listViewCtrl.BackColor);						
 		Console.WriteLine ("ItemActivation " + listViewCtrl.Activation);				
 		Console.WriteLine ("ColumnHeaderStyle " + listViewCtrl.HeaderStyle);				
+		Console.WriteLine ("BorderStyle " + listViewCtrl.BorderStyle);				
 		
-				
+		ListViewItem item = new ListViewItem();
+		
+		Console.WriteLine ("ListView item----");
+		Console.WriteLine ("BackColor " + item.BackColor);		
+		Console.WriteLine ("ForeColor  " + item.ForeColor);		
+		Console.WriteLine ("UseItemStyleForSubItems  " + item.UseItemStyleForSubItems);		
+				 
 	}
 	
 	public MyListViewForm()
@@ -141,7 +183,7 @@ public class MyListViewForm : System.Windows.Forms.Form
 		
 		ShowClassDefaults();
 		
-		listViewCtrl.HeaderStyle = ColumnHeaderStyle.None;
+		
 		
 		// Set params
 		listViewCtrl.View = View.Details;			
@@ -150,23 +192,31 @@ public class MyListViewForm : System.Windows.Forms.Form
 		listViewCtrl.FullRowSelect = true;	
 		listViewCtrl.GridLines = true;
 		listViewCtrl.Activation = ItemActivation.OneClick;
-			 
+		
 		
     	listViewCtrl.Bounds = new Rectangle(new Point(10,60), new Size(600, 550));
     	ListViewItem item1 = new ListViewItem("item1");
-    	ListViewItem item2 = new ListViewItem("item2");
+    	ListViewItem item2 = new ListViewItem("Yellow item");
     	ListViewItem item3 = new ListViewItem("item3");
     	ListViewItem item4 = new ListViewItem("item4");
     	ListViewItem item5 = new ListViewItem("item5");
-    	ListViewItem item6 = new ListViewItem("item6");
+    	ListViewItem item6 = new ListViewItem("Green item");
     	ListViewItem item7 = new ListViewItem("item7");
     	ListViewItem item8 = new ListViewItem("item8");
     	ListViewItem item9 = new ListViewItem("item9");
-    	ListViewItem item10 = new ListViewItem("item10 aaaaaaaaaaaaaaaaaaaaaaaaa");
-
-		Console.WriteLine ("*Column 1");			    	
-   	    column1 = listViewCtrl.Columns.Add("Column 1", -1, HorizontalAlignment.Left);
-   	    Console.WriteLine ("*Column 2");			    	
+    	ListViewItem item10 = new ListViewItem("This is a long text");
+    	
+    	    	
+    	ListViewItem.ListViewSubItem subItem11_1 = new ListViewItem.ListViewSubItem();          	
+    	ListViewItem.ListViewSubItem subItem11_2 = new ListViewItem.ListViewSubItem();          	
+    	
+    	//ListViewItem item11 = new ListViewItem(new ListViewItem.ListViewSubItem[]{subItem11_1, subItem11_2});
+    	//listViewCtrl.Items.Add( new ListViewItem(new string[]{"boy 1", "boy 2", "boy 3"}));
+    	
+    	subItem11_1.Text  = "subitem 11-1";
+    	subItem11_2.Text  = "subitem 11-2";    	    		
+		
+   	    column1 = listViewCtrl.Columns.Add("Column 1", -1, HorizontalAlignment.Left);   	    
    	   	column2 =  listViewCtrl.Columns.Add("Column 2", -2, HorizontalAlignment.Right);
    	   	column3 =  listViewCtrl.Columns.Add("Column 3", 50, HorizontalAlignment.Right);
    	   	column4 =  new ColumnHeader();
@@ -174,8 +224,19 @@ public class MyListViewForm : System.Windows.Forms.Form
    	   	column4.Text="Column 4";
    	   	column4.Width= 150;
    	   	
-   	   	//listViewCtrl.Columns.AddRange(new ColumnHeader[]{column4});
-   	    
+   	   	   	   	
+   	   	item2.BackColor = Color.Yellow;  		   	 
+   	   	item2.ForeColor  = Color.Blue;
+   	   	item2.SubItems.Add("yellow-blue subitem 1");          	
+   	   	item2.SubItems.Add("yellow-blue subitem 2");          	
+   	   	
+   	   	item6.BackColor = Color.Green;  		   	 
+   	   	item6.UseItemStyleForSubItems = false;
+   	   	ListViewItem.ListViewSubItem subItem= item6.SubItems.Add("Red subitem 1");          	
+   	   	subItem.BackColor = Color.Red;  		   	 
+   	   	subItem.ForeColor = Color.White;  		   	 
+   	   	    
+   	   	  	    
 		listViewCtrl.Items.Add(item1);					
 		listViewCtrl.Items.Add(item2);					
 		
@@ -226,6 +287,14 @@ public class MyListViewForm : System.Windows.Forms.Form
 		button2.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
 		Controls.Add(button2); 
 		
+		CheckedItemButton button8 = new CheckedItemButton(this);		
+		button8.Location = new System.Drawing.Point(630, 50);
+		button8.Name = "button2";
+		button8.Size = new System.Drawing.Size(100, 30);		
+		button8.Text = "Checked on/off";
+		button8.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+		Controls.Add(button8); 
+		
 		DumpSelButton button3 = new DumpSelButton(this);		
 		button3.Location = new System.Drawing.Point(630, 120);
 		button3.Name = "button3";
@@ -242,6 +311,13 @@ public class MyListViewForm : System.Windows.Forms.Form
 		button4.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
 		Controls.Add(button4);    	
 		
+		ItemPropButton button9 = new ItemPropButton(this);		
+		button9.Location = new System.Drawing.Point(630, 180);
+		button9.Name = "button9";
+		button9.Size = new System.Drawing.Size(100, 30);		
+		button9.Text = "Item Properties";
+		button9.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+		Controls.Add(button9);    		
     	
     	Controls.Add(listViewCtrl);
 	}
@@ -342,6 +418,41 @@ public class ClearColumnsButton : System.Windows.Forms.Button{
 		}
 }
 
+// CheckedItemButton
+public class CheckedItemButton : System.Windows.Forms.Button{
+		MyListViewForm form = null;
+
+		public CheckedItemButton(MyListViewForm frm) : base()
+		{
+			form =  frm;
+			
+		}
+		
+		/* User clicks the button*/
+		protected override void OnClick(EventArgs e) 
+		{	
+			form.CheckedItemButton();
+		}
+}
+
+// ItemPropButton
+public class ItemPropButton : System.Windows.Forms.Button{
+		MyListViewForm form = null;
+
+		public ItemPropButton(MyListViewForm frm) : base()
+		{
+			form =  frm;
+			
+		}
+		
+		/* User clicks the button*/
+		protected override void OnClick(EventArgs e) 
+		{	
+			form.ItemPropButton();
+		}
+}
+
+
 
 // AddColumnsButton
 public class AddColumnsButton : System.Windows.Forms.Button{

+ 15 - 18
mcs/class/System.Windows.Forms/System.Windows.Forms/ColumnHeader.cs

@@ -27,10 +27,8 @@ namespace System.Windows.Forms {
 		private ListView container = null;
 		int serial = 0;
 		
-		/// --- constructor ---
-		[MonoTODO]
-		public ColumnHeader() : base () 
-		{
+		/// --- constructor ---		
+		public ColumnHeader() : base () {
 			text = null;
 			textAlign = HorizontalAlignment.Left;
 			width = -2;
@@ -38,19 +36,24 @@ namespace System.Windows.Forms {
 		}
 		
 		//
-		//  --- Private Methods
-		//		
-		public ListView Container 
-		{			
+		//  --- Internal Methods for the implementation
+		//
+		internal int Serial {
+			get { return serial; }
+			set { serial = value; }
+		}
+		
+		internal ListView Container {			
 			set{container=value;}
 		}		
 		
-		public int CtrlIndex{			
+		internal int CtrlIndex{			
 			set{index=value;}
 		}		
 		
-		// --- Properties ---
-		
+		//
+		// --- Public Properties ---
+		//		
 		public int Index {
 			get { return index; }
 		}		
@@ -64,18 +67,12 @@ namespace System.Windows.Forms {
 			set { text = value; }
 		}
 		
-		// Not in the .Net spec
-		public int Serial {
-			get { return serial; }
-			set { serial = value; }
-		}
 		
 		public HorizontalAlignment TextAlign {
 			get { return textAlign; }
 			set { textAlign = value; }
-		}
+		}		
 		
-		[MonoTODO]
 		public int Width {
 			get { return width; }
 			set { width = value; }

+ 128 - 68
mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs

@@ -48,6 +48,8 @@ namespace System.Windows.Forms {
 		private CheckedIndexCollection chkIndexCol = null;
 		private	ItemActivation	activation = ItemActivation.Standard; 
 		private ColumnHeaderStyle headerStyle = ColumnHeaderStyle.Clickable;
+		private	BorderStyle borderStyle = BorderStyle.Fixed3D;
+		bool bScrollable = true;
 				
 		
 		//
@@ -128,15 +130,10 @@ namespace System.Windows.Forms {
 				base.BackgroundImage = value;
 			}
 		}
-		[MonoTODO]
+		
 		public BorderStyle BorderStyle {
-			get {
-				//throw new NotImplementedException ();
-				return 0;
-			}
-			set {
-				//throw new NotImplementedException ();
-			}
+			get { return borderStyle;  }
+			set { borderStyle = value; }			
 		}
 		
 		public bool CheckBoxes {
@@ -243,14 +240,10 @@ namespace System.Windows.Forms {
 			set {bMultiSelect=value;}
 		}
 		
-		[MonoTODO]
+		
 		public bool Scrollable {
-			get {				
-				throw new NotImplementedException ();
-			}
-			set {
-				//throw new NotImplementedException ();
-			}
+			get {return bScrollable;}			
+			set {bScrollable=value;}
 		}
 		
 		public ListView.SelectedIndexCollection SelectedIndices {
@@ -395,7 +388,8 @@ namespace System.Windows.Forms {
 				if (AutoArrange) createParams.Style |= (int) ListViewFlags.LVS_AUTOARRANGE;
 				if (!bLabelWrap)  createParams.Style |= (int) ListViewFlags.LVS_NOLABELWRAP;
 				if (!bMultiSelect) createParams.Style |= (int) ListViewFlags.LVS_SINGLESEL;
-				
+				if (!bScrollable)  createParams.Style |= (int) ListViewFlags.LVS_NOSCROLL;
+								
 				switch (headerStyle)
 				{
 					case ColumnHeaderStyle.Clickable:	// Default						
@@ -409,6 +403,21 @@ namespace System.Windows.Forms {
 					default:	
 						break;				
 				}
+				
+				switch (borderStyle)
+				{
+					case BorderStyle.Fixed3D:	
+						createParams.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
+						break;
+					case BorderStyle.FixedSingle:
+						createParams.Style |= (int) WindowStyles.WS_BORDER;
+						break;
+					case BorderStyle.None:
+						//createParams.ExStyle |= (int) ListViewFlags.LVS_NOCOLUMNHEADER;
+						break;
+					default:	
+						break;				
+				}
 									
 				return createParams;
 			}		
@@ -436,21 +445,11 @@ namespace System.Windows.Forms {
 		}
 
 		
-		[MonoTODO]
-		protected virtual void  OnAfterLabelEdit(LabelEditEventArgs e) {
-			//FIXME:
-		}
-		
-		[MonoTODO]
-		protected virtual void  OnBeforeLabelEdit(LabelEditEventArgs e) {
-			//FIXME:
-		}
-		
-		
-		[MonoTODO]
-		protected virtual void  OnColumnClick(ColumnClickEventArgs e) {
-			//FIXME:
-		}
+		// Implemented
+		protected virtual void  OnAfterLabelEdit(LabelEditEventArgs e) {}		
+		protected virtual void  OnBeforeLabelEdit(LabelEditEventArgs e) {}		
+		protected virtual void  OnColumnClick(ColumnClickEventArgs e) {}
+		protected virtual void  OnItemActivate(EventArgs e) 	{}
 
 		[MonoTODO]
 		protected override void OnEnabledChanged(EventArgs e) {
@@ -473,9 +472,7 @@ namespace System.Windows.Forms {
 			//FIXME:
 		}
 
-		protected virtual void  OnItemActivate(EventArgs e) 	{
-			//FIXME:
-		}
+		
 		[MonoTODO]
 		protected virtual void  OnItemCheck(ItemCheckEventArgs e) {
 			//FIXME:
@@ -736,7 +733,14 @@ namespace System.Windows.Forms {
 			Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETBKCOLOR, 0, 	(int) (backColor.R | backColor.G<<8 | backColor.B <<16));  			
 		}				
 		
-		public void insertItemsInCtrl()	{
+		// Sets Background color in an item
+		internal void SetItemBkColorCtrl(Color col){	
+			
+			if (!bInitialised) return;					
+			Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETTEXTBKCOLOR, 0, 	(int) (col.R | col.G<<8 | col.B <<16));  			
+		}				
+		
+		internal void insertItemsInCtrl()	{
 			
 			Win32.SendMessage(Handle, (int)ListViewMessages.LVM_DELETEALLITEMS, 0,0);			
 		
@@ -854,10 +858,8 @@ namespace System.Windows.Forms {
 						NMITEMACTIVATE NmItemAct = (NMITEMACTIVATE)Marshal.PtrToStructure (m.LParam,	typeof (NMITEMACTIVATE));								
 						
 						Console.WriteLine("ListViewMessages.LVN_ITEMACTIVATE " + NmItemAct.iItem + "sub: " + NmItemAct.iSubItem);    						
-						
-						EventArgs ice = new EventArgs();
-					
-						OnItemActivate(ice);
+																	
+						OnItemActivate(new EventArgs());
 							
 						break;
 					}
@@ -869,28 +871,36 @@ namespace System.Windows.Forms {
 						
 						Console.WriteLine("ListViewMessages.LVN_ITEMCHANGED item:" + NmLstView.iItem + " sub: "+ NmLstView.iSubItem + "att:" +NmLstView.uChanged);    											
 						
-						selItemsCol.Clear();
+						// NOTE: Using the LVIS_SELECTED status does not work well when you use the control
+						// to select diferent items.
+
+						// Selected						
+						selItemsCol.Clear();						
+						for (int i=0; i < selItemIndexs.Count; i++)						
+							Items[selItemIndexs[i]].Selected=false;				
 						
 						int nItem = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETNEXTITEM, -1, (int) ListViewNotifyItem.LVNI_SELECTED);
-						
+												
 						while (nItem!=-1)
 						{
 							selItemsCol.Add(nItem);								
+							Items[nItem].Selected=true;				
 							nItem = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETNEXTITEM, nItem, (int) ListViewNotifyItem.LVNI_SELECTED);
 						}
 						
-						int nItems = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETITEMCOUNT, 0, 0);  			
-						
-						Console.WriteLine("Items " + nItems);    											
-						
+						// Check checked items
+						int nItems = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETITEMCOUNT, 0, 0);  					
+					
 						chkItemCol.Clear();
+						for (int i=0; i < chkItemCol.Count; i++)						
+							Items[i].Checked = false;				
 						
-						for (int i=0; i<nItems; i++)
-							if (GetCheckStateInCtrl(i))
-							{
+						for (int i=0; i<nItems; i++){
+							if (GetCheckStateInCtrl(i))	{
 								chkItemCol.Add(i);
-								Console.WriteLine("Item checked " + i);    											
+								Items[i].Checked = true;												   											
 							}						
+						}
 						
 						break;
 					}
@@ -913,6 +923,61 @@ namespace System.Windows.Forms {
 												   																										
 						break;	
 					}
+					
+					// Used to paint item colours and font
+					case (int)NotificationMessages.NM_CUSTOMDRAW:
+					{						
+						NMLVCUSTOMDRAW LVNmCustom = (NMLVCUSTOMDRAW)Marshal.PtrToStructure (m.LParam,	typeof (NMLVCUSTOMDRAW));																																		
+					
+						switch(LVNmCustom.nmcd.dwDrawStage)    {							
+						
+						case (int)CustomDrawDrawStateFlags.CDDS_PREPAINT:														
+							m.Result = (IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYITEMDRAW;
+							return;
+					
+						case (int)CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT:						    						    	
+														
+							if (Items[(int)LVNmCustom.nmcd.dwItemSpec].UseItemStyleForSubItems)	{						
+							  
+								LVNmCustom.clrTextBk = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].BackColor);						
+								LVNmCustom.clrText = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].ForeColor);						
+								Marshal.StructureToPtr(LVNmCustom, m.LParam, false);								        				        
+								m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;		    								
+							}
+							else
+								m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYSUBITEMDRAW;																		
+							
+							return;
+								
+						  case (int)(CustomDrawDrawStateFlags.CDDS_SUBITEM  | CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT):						  						  
+						  
+						  	ListViewItem item = Items[(int)LVNmCustom.nmcd.dwItemSpec];						    
+						    
+						    if (LVNmCustom.iSubItem==0)    {						    	
+						    	LVNmCustom.clrTextBk = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].BackColor);						
+						    	LVNmCustom.clrText = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].ForeColor);
+								Marshal.StructureToPtr(LVNmCustom, m.LParam, false);								        				        
+								m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;		    								
+							}
+							else{						    															
+								
+								ListViewItem.ListViewSubItem subItem;
+								subItem = item.SubItems[(int)LVNmCustom.iSubItem-1];																																	
+						    	LVNmCustom.clrTextBk = (uint) Win32.RGB (subItem.BackColor);												    							  								    	
+						    	LVNmCustom.clrText = (uint) Win32.RGB (subItem.ForeColor);												    							  								    	
+						  	}
+						  	
+						  	Marshal.StructureToPtr(LVNmCustom, m.LParam, false);
+						  	m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;			
+						  	return;				
+						  	
+							
+						default: 							
+							break;
+					    }						    
+						
+						break;
+					}	
 											
 					default:
 						break;
@@ -967,13 +1032,13 @@ namespace System.Windows.Forms {
 			}
 			
 			//
-			//  --- Private Methods for the implementation
+			//  --- Internal Methods for the implementation
 			//
-			public void Add (int nIndex) {
+			internal void Add (int nIndex) {
 				collection.Add(nIndex);
 			}			
 			
-			public void Remove (int nIndex) {
+			internal void Remove (int nIndex) {
 				collection.Remove(nIndex);
 			}			
 
@@ -1024,8 +1089,7 @@ namespace System.Windows.Forms {
 			object IList.this[int index]{
 				get { return collection[index]; }
 				set { collection[index] = value; }
-			}
-		
+			}		
 
 			void IList.Clear(){
 				collection.Clear();
@@ -1107,7 +1171,7 @@ namespace System.Windows.Forms {
 			//  --- Constructor
 			//			
 			public CheckedListViewItemCollection(ListView owner) 	{				
-				container = owner;
+				container = owner;				
 			}
 
 			//
@@ -1118,7 +1182,7 @@ namespace System.Windows.Forms {
 			}
 			
 			public bool IsReadOnly {
-				get {return collection.IsReadOnly;}
+				get {return true;}	
 			} 			
 			
 			public virtual ListViewItem this[int index] {				
@@ -1126,12 +1190,14 @@ namespace System.Windows.Forms {
 				set { collection[index] = value.Index;}	
 			}
 			
-			// Internal
-			public void Clear() {
+			//
+			//  --- Internal Methods for the implementation
+			//
+			internal void Clear() {
 				 collection.Clear();  
 			}
 			
-			public void Add (int nIndex) {
+			internal void Add (int nIndex) {
 				collection.Add(nIndex);
 			}				
 
@@ -1165,19 +1231,13 @@ namespace System.Windows.Forms {
 				return collection.IndexOf(item);
 			}
 			/// <summary>
-			/// IList Interface implmentation.
+			/// IList Interface implementation.
 			/// </summary>
 			bool IList.IsReadOnly{
-				get{
-					// We allow addition, removeal, and editing of items after creation of the list.
-					return false;
-				}
+				get{return true;}
 			}
 			bool IList.IsFixedSize{
-				get{
-					// We allow addition and removeal of items after creation of the list.
-					return false;
-				}
+				get{return true;}
 			}
 
 			//[MonoTODO]

+ 77 - 123
mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewItem.cs

@@ -24,35 +24,33 @@ namespace System.Windows.Forms
 		private string  m_sText;
 		private	ListViewSubItemCollection	m_colSubItem = null;
 		private int index;
-		
-		/* Properties */
-		private	Color	m_BackColor = SystemColors.Window;
+		private bool bSelected = false;
+		private bool useItemStyleForSubItems = true;
+		private bool bChecked = false;
+		private bool bFocused = false;
+		private	Color backColor = SystemColors.Window;
+		private	Color foreColor = SystemColors.WindowText;
 		private	System.Drawing.Rectangle m_Bounds;
 
 		//
 		//  --- Constructor
-		//			
-		
-		internal void CommonConstructor()
-		{
+		//					
+		protected void CommonConstructor(){
 			m_colSubItem = new 	ListViewSubItemCollection(this);
 		}
 		
-		public ListViewItem()		
-		{
-			Console.WriteLine("ListView.ListView");							
+		public ListViewItem(){			
 			CommonConstructor();			
 		}
 		
-		public ListViewItem(string str)
-		{
+		public ListViewItem(string str)	{
 			Console.WriteLine("ListViewItem.ListViewItem str");					
 			CommonConstructor();			
 			m_sText = str;
 		}
 		
-		public ListViewItem(string[] strings)	// An array of strings that represent the subitems of the new item.
-		{
+		public ListViewItem(string[] strings){	// An array of strings that represent the subitems of the new item.
+		
 			Console.WriteLine("ListView.ListView strings");				
 			CommonConstructor();
 			
@@ -66,10 +64,12 @@ namespace System.Windows.Forms
 			}
 		}
 
-		[MonoTODO]
-		public ListViewItem(ListViewItem.ListViewSubItem[] subItems)
-		{
-			throw new NotImplementedException();
+		
+		public ListViewItem(ListViewItem.ListViewSubItem[] subItems){
+			
+			CommonConstructor();
+			for (int i=0; i<subItems.Length; i++)
+					m_colSubItem.Add(subItems[i]);		
 		}
 
 		[MonoTODO]
@@ -101,18 +101,14 @@ namespace System.Windows.Forms
 		{
 			throw new NotImplementedException ();
 		}
+		
 
 		//
 		//  --- Public Properties
-		//
-		[MonoTODO]
+		//		
 		public Color BackColor {
-			get {
-				return m_BackColor;
-			}
-			set {
-				m_BackColor = value;
-			}
+			get {return backColor;}
+			set {backColor = value;}
 		}
 
 		[MonoTODO]
@@ -124,25 +120,16 @@ namespace System.Windows.Forms
 				return m_Bounds;
 			}
 		}
-
-		[MonoTODO]
+		
 		public bool Checked {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get {return bChecked;}
+			set {bChecked = value;}
 		}
 
-		[MonoTODO]
+		
 		public bool Focused {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get {return bFocused;}
+			set {bFocused = value;}
 		}
 
 		[MonoTODO]
@@ -155,14 +142,9 @@ namespace System.Windows.Forms
 			}
 		}
 
-		[MonoTODO]
-		public Color Forecolor {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+		public Color ForeColor {
+			get {return foreColor;}
+			set {foreColor = value;}
 		}
 		[MonoTODO]
 		public int ImageIndex {
@@ -188,14 +170,10 @@ namespace System.Windows.Forms
 		public ListView ListView {
 			get {return container;}						
 		}
-		[MonoTODO]
+		
 		public bool Selected {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get {return bSelected;}						
+			set {bSelected=value;}									
 		}
 		[MonoTODO]
 		public int StateImageIndex  {
@@ -223,21 +201,16 @@ namespace System.Windows.Forms
 				//FIXME:
 			}
 		}
-		[MonoTODO]
-		public string Text 
-		{
+		
+		public string Text 	{
 			get { return m_sText;}
 			set { m_sText = value;}		
 			
 		}
-		[MonoTODO]
+		
 		public bool UseItemStyleForSubItems {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get { return useItemStyleForSubItems;}
+			set { useItemStyleForSubItems = value;}		
 		}
 		
 		//
@@ -330,8 +303,7 @@ namespace System.Windows.Forms
 			//
 			//  --- Constructor
 			//		
-			public ListViewSubItemCollection(ListViewItem owner) 
-			{
+			public ListViewSubItemCollection(ListViewItem owner) {
 				m_owner = owner;
 			}			
 			
@@ -387,16 +359,15 @@ namespace System.Windows.Forms
 				return (ListViewSubItem)m_collection[nIdx]; // TODO: Check this in .Net?
 			} 
 			
-			[MonoTODO]
+			
 			public ListViewSubItem Add(string text) 
 			{
 				
 				Console.WriteLine("ListViewSubItem.Add " +  text);											
-				ListViewItem.ListViewSubItem item = new ListViewSubItem(m_owner, text);	 //aki
-				
+				ListViewItem.ListViewSubItem item = new ListViewSubItem(m_owner, text);	 
 						
 				int nIdx = m_collection.Add(item); 
-				return (ListViewSubItem)m_collection[nIdx]; // TODO: Check this in .Net?
+				return (ListViewSubItem)m_collection[nIdx]; 
 			}
 			
 			[MonoTODO]
@@ -516,81 +487,64 @@ namespace System.Windows.Forms
 	// <summary>
 	// </summary>
 
-	public class ListViewSubItem  //aka
+	public class ListViewSubItem  
 	{
 		
-		private string  m_sText;
-		public ListViewItem m_owner = null;
-		//private int index;
-		/*
-		public int CtrlIndex
-		{					
-			get{retrun index}
-			set{index=value;}
-		}*/
+		private string  sText;
+		private ListViewItem owner = null;
+		private	Color backColor = SystemColors.Window;
+		private	Color foreColor = SystemColors.WindowText;
+		private Font font;
 		
-		public ListViewItem ListViewItem
-		{
-			get{return m_owner;}
+		
+		public ListViewItem ListViewItem{
+			get{return owner;}
 		}
 	
 		//
 		//  --- Constructor
 		//
-		public ListViewSubItem()
-		{
+		public ListViewSubItem(){
 			
 		}
 		
-		public ListViewSubItem(ListViewItem item, string str)
-		{
-			m_owner = item;
-			m_sText = str;
+		public ListViewSubItem(ListViewItem item, string str){
+			
+			owner = item;
+			sText = str;
 		}
 		
-		public ListViewSubItem(ListViewItem item, string str, Color color1, Color color2, Font font)
-		{
-			throw new NotImplementedException();
+		public ListViewSubItem(ListViewItem item, string str, Color foreClr, Color backClr, Font fnt){
+			
+			owner = item;
+			sText = str;
+			BackColor = backClr;
+			ForeColor = foreClr;			
+			font = fnt;
 		}
 	
 		//
 		//  --- Public Properties
 		//
-		[MonoTODO]
 		public Color BackColor {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get {return backColor;}
+			set {backColor = value;}
 		}
-		[MonoTODO]
+
+		
 		public Font Font {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
+			get {return font;}
+			set {font = value;}
 		}
-		[MonoTODO]
+		
 		public Color ForeColor {
-			get {
-				throw new NotImplementedException ();
-			}
-			set {
-				//FIXME:
-			}
-		}
-		[MonoTODO]
+			get {return foreColor;}
+			set {foreColor = value;}
+		}		
+		
 		public string Text {
-			get {
-				return m_sText;
-			}
-			set {
-				//FIXME:
-			}
+			get {return sText;}
+			set {sText=value;}
 		}
 
 		//

+ 6 - 5
mcs/class/System.Windows.Forms/System.Windows.Forms/win32Structs.cs

@@ -162,11 +162,11 @@ namespace System.Windows.Forms
 	internal struct NMCUSTOMDRAW
 	{
 		internal NMHDR hdr;
-		internal int dwDrawStage;
+		internal uint dwDrawStage;
 		internal IntPtr hdc;
 		internal RECT rc;
 		internal int dwItemSpec;
-		internal int uItemState;
+		internal uint uItemState;
 		internal IntPtr lItemlParam;
 	}
 	#endregion
@@ -196,9 +196,10 @@ namespace System.Windows.Forms
 	internal struct NMLVCUSTOMDRAW 
 	{
 		internal NMCUSTOMDRAW nmcd;
-		internal int clrText;
-		internal int clrTextBk;
-		internal int iSubItem;
+		internal uint clrText;
+		internal uint clrTextBk;
+		internal uint iSubItem;
+    
 	} 
 	#endregion