Просмотр исходного кода

2009-05-18 Carlos Alberto Cortez <[email protected]>

	* DateTimePicker.cs: When calculating the max width for the year part,
	use the current value, since *all* the possible values are exactly a 4
	digits number. This way we avoid a ArgumentOutOfRangeException trying
	to check against different values.
	Fixes #500917.


svn path=/trunk/mcs/; revision=134317
Carlos Alberto Cortez 16 лет назад
Родитель
Сommit
5d36614029

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

@@ -1,3 +1,11 @@
+2009-05-18  Carlos Alberto Cortez <[email protected]>
+
+	* DateTimePicker.cs: When calculating the max width for the year part,
+	use the current value, since *all* the possible values are exactly a 4
+	digits number. This way we avoid a ArgumentOutOfRangeException trying
+	to check against different values.
+	Fixes #500917.
+
 2009-05-15  Carlos Alberto Cortez <[email protected]>
 
 	* MessageBox.cs: When handling ProcessDialogChar, check that

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

@@ -1099,11 +1099,11 @@ namespace System.Windows.Forms {
 				case "y":
 				case "yy":
 				case "yyyy":
-					for (int i = 1; i <= 10; i++) {
-						text = PartData.GetText (Value.AddYears (i), format);
-						size = gr.MeasureString (text, font, int.MaxValue, string_format);
-						result = Math.Max (result, size.Width);
-					}
+					// Actually all the allowed year values are between MinDateTime and MaxDateTime,
+					// which are 4 digits always
+					text = PartData.GetText (Value, format);
+					size = gr.MeasureString (text, font, int.MaxValue, string_format);
+					result = Math.Max (result, size.Width);
 					return result;
 				default:
 					return gr.MeasureString (format, font, int.MaxValue, string_format).Width;