From: Miguel de Icaza Date: Fri, 13 Jan 2012 23:58:53 +0000 (-0500) Subject: Apply fix for 2839 from Michael Mudge X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=31de7582bd540c8b785900bdb524445f54da3c38;p=mono.git Apply fix for 2839 from Michael Mudge --- diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs index e824ff1fe48..cc60cc257e7 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs @@ -237,8 +237,8 @@ namespace System.Windows.Forms if (value != auto_size) { auto_size = value; if (auto_size) { - if (PreferredHeight != ClientSize.Height) { - ClientSize = new Size(ClientSize.Width, PreferredHeight); + if (PreferredHeight != Height) { + Height = PreferredHeight; } } } @@ -466,14 +466,16 @@ namespace System.Windows.Forms [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [EditorBrowsable(EditorBrowsableState.Advanced)] + // This returns the preferred outer height, not the client height. public int PreferredHeight { get { + int clientDelta = Height - ClientSize.Height; if (BorderStyle != BorderStyle.None) - return Font.Height + 7; + return Font.Height + 7 + clientDelta; // usually in borderless mode the top margin is 0, but // try to access it, in case it was set manually, as ToolStrip* controls do - return Font.Height + TopMargin; + return Font.Height + TopMargin + clientDelta; } } @@ -993,7 +995,7 @@ namespace System.Windows.Forms base.OnFontChanged (e); if (auto_size && !document.multiline) { - if (PreferredHeight != ClientSize.Height) { + if (PreferredHeight != Height) { Height = PreferredHeight; } } @@ -1762,8 +1764,8 @@ namespace System.Windows.Forms { if (!richtext) { if (!document.multiline) { - if (PreferredHeight != ClientSize.Height) { - ClientSize = new Size (ClientSize.Width, PreferredHeight); + if (PreferredHeight != Height) { + Height = PreferredHeight; } } }