Ver código fonte

2005-08-08 Jordi Mas i Hernandez <[email protected]>

	* ComboBox.cs: Serveral fixes
	* ListBox.cs: Serveral fixes


svn path=/trunk/mcs/; revision=48124
Jordi Mas i Hernandez 20 anos atrás
pai
commit
93d35ffd5d

+ 5 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2005-08-08  Jordi Mas i Hernandez <[email protected]>
+
+	* ComboBox.cs: Serveral fixes
+	* ListBox.cs: Serveral fixes
+
 2005-08-05  Jordi Mas i Hernandez <[email protected]>
 
 	* ComboBox.cs: Fixes FindString methods and GetItemHeight

+ 17 - 7
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs

@@ -62,7 +62,7 @@ namespace System.Windows.Forms
 		private ComboListBox listbox_ctrl;		
 		private TextBox textbox_ctrl;
 		private bool process_textchanged_event;
-		private bool has_focus;		
+		private bool has_focus;	
 
 		[ComVisible(true)]
 		public class ChildAccessibleObject : AccessibleObject {
@@ -94,6 +94,7 @@ namespace System.Windows.Forms
 			internal int original_height;		/* Control's height is recalculated for not Simple Styles */
 			internal Rectangle listbox_area;	/* ListBox area in Simple combox, not used in the rest */
 			internal bool droppeddown;		/* Is the associated ListBox dropped down? */
+			internal int combosimple_height;	/* Simple default height */
 
 			public ComboBoxInfo ()
 			{
@@ -102,6 +103,7 @@ namespace System.Windows.Forms
 				item_height = 0;
 				droppeddown = false;
 				original_height = -1;
+				combosimple_height = 150;
 			}
 		}
 
@@ -250,10 +252,8 @@ namespace System.Windows.Forms
 				dropdown_style = value;					
 				
 				if (dropdown_style == ComboBoxStyle.Simple) {
-					CBoxInfo.show_button = false;
-					
-					if (combobox_info.original_height != -1)
-						Height = combobox_info.original_height;
+					CBoxInfo.show_button = false;					
+					Height = combobox_info.combosimple_height;
 					
 					CreateComboListBox ();
 
@@ -361,7 +361,7 @@ namespace System.Windows.Forms
 			get { return combobox_info.item_height; }
 			set {
 				if (value < 0)
-					throw new ArgumentOutOfRangeException ("The item height value is less than zero");
+					throw new ArgumentException ("The item height value is less than zero");
 
 				combobox_info.item_height = value;
 				CalcTextArea ();
@@ -420,7 +420,7 @@ namespace System.Windows.Forms
 		public override int SelectedIndex {
 			get { return selected_index; }
 			set {
-				if (value < -2 || value >= Items.Count)
+				if (value <= -2 || value >= Items.Count)
 					throw new ArgumentOutOfRangeException ("Index of out range");
 
 				if (selected_index == value)
@@ -626,6 +626,9 @@ namespace System.Windows.Forms
 
 		public int FindString (string s, int startIndex)
 		{
+			if (Items.Count == 0) 
+				return -1; // No exception throwing if empty
+
 			if (startIndex < -1 || startIndex >= Items.Count - 1)
 				throw new  ArgumentOutOfRangeException ("Index of out range");
 
@@ -645,6 +648,9 @@ namespace System.Windows.Forms
 
 		public int FindStringExact (string s, int startIndex)
 		{
+			if (Items.Count == 0) 
+				return -1; // No exception throwing if empty
+
 			if (startIndex < -1 || startIndex >= Items.Count - 1)
 				throw new ArgumentOutOfRangeException ("Index of out range");
 
@@ -777,6 +783,7 @@ namespace System.Windows.Forms
 
 			if (listbox_ctrl != null) {
 				Controls.Add (listbox_ctrl);
+				Height = combobox_info.combosimple_height;
 			}
 			
 			if (textbox_ctrl != null) {
@@ -872,6 +879,9 @@ namespace System.Windows.Forms
 
 		protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
 		{
+			if ((specified & BoundsSpecified.Height) != 0)
+				combobox_info.combosimple_height = height;
+
 			base.SetBoundsCore (x, y, width, height, specified);
 		}
 

+ 8 - 5
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs

@@ -267,7 +267,7 @@ namespace System.Windows.Forms
 		public int ColumnWidth {
 			get { return column_width; }
 			set {
-				if (column_width < 0)
+				if (value < 0)
 					throw new ArgumentException ("A value less than zero is assigned to the property.");
 
     				column_width = value;
@@ -299,7 +299,7 @@ namespace System.Windows.Forms
 					throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for DrawMode", value));
 					
 				if (value == DrawMode.OwnerDrawVariable && multicolumn == true)
-					throw new InvalidEnumArgumentException ("Cannot have variable height and multicolumn");
+					throw new ArgumentException ("Cannot have variable height and multicolumn");
 
 				if (draw_mode == value)
 					return;
@@ -435,9 +435,6 @@ namespace System.Windows.Forms
 		public override RightToLeft RightToLeft {
 			get { return base.RightToLeft; }
 			set {
-				if (base.RightToLeft == value)
-					return;
-
     				base.RightToLeft = value;    				
 				base.Refresh ();
 			}
@@ -678,6 +675,9 @@ namespace System.Windows.Forms
 
 		public int FindString (string s,  int startIndex)
 		{
+			if (Items.Count == 0)
+				return -1; // No exception throwing if empty
+
 			if (startIndex < -1 || startIndex >= Items.Count - 1)
 				throw new ArgumentOutOfRangeException ("Index of out range");
 
@@ -697,6 +697,9 @@ namespace System.Windows.Forms
 
 		public int FindStringExact (string s,  int startIndex)
 		{
+			if (Items.Count == 0)
+				return -1; // No exception throwing if empty
+
 			if (startIndex < -1 || startIndex >= Items.Count - 1)
 				throw new ArgumentOutOfRangeException ("Index of out range");