[MWF] Adjust DataGridViewRow.Height according to MinimumHeight
authorEberhard Beilharz <eb1@sil.org>
Tue, 11 Mar 2014 14:23:08 +0000 (15:23 +0100)
committerEberhard Beilharz <eb1@sil.org>
Wed, 12 Mar 2014 15:42:44 +0000 (16:42 +0100)
When the MinimumHeight gets changed to a value less than Height
we set height to the new minimum height (and fire the
DataGridView.RowMinimumHeightChanged event). This matches the
behavior on .NET.

When the user tries to set Height to a value less than MinimumHeight
we silently set the height to the minimum height (instead of
throwing an exception). This matches also the behavior on .NET.

mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs

index df638ee5dd1a771b1e7ded164d5038ca879a0c42..8130f70df0a6003fc6b5249e996e120d7c90d15f 100644 (file)
@@ -196,9 +196,10 @@ namespace System.Windows.Forms
                                
                                if (height != value) {
                                        if (value < minimumHeight) {
-                                               throw new ArgumentOutOfRangeException("Height can't be less than MinimumHeight.");
+                                               height = minimumHeight;
+                                       } else {
+                                               height = value;
                                        }
-                                       height = value;
                                        if (DataGridView != null) {
                                                DataGridView.Invalidate ();
                                                DataGridView.OnRowHeightChanged(new DataGridViewRowEventArgs(this));
@@ -254,6 +255,10 @@ namespace System.Windows.Forms
                                        if (value < 2 || value > Int32.MaxValue) {
                                                throw new ArgumentOutOfRangeException("MinimumHeight should be between 2 and Int32.MaxValue.");
                                        }
+                                       if (height < value) {
+                                               // don't let height get less than minimumHeight!
+                                               Height = value;
+                                       }
                                        minimumHeight = value;
                                        if (DataGridView != null) {
                                                DataGridView.OnRowMinimumHeightChanged(new DataGridViewRowEventArgs(this));