NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TextBoxBase.PreferredHeight

Returns the preferred height for a single-line text box.

[Visual Basic]
Public ReadOnly Property PreferredHeight As Integer
[C#]
public int PreferredHeight {get;}
[C++]
public: __property int get_PreferredHeight();
[JScript]
public function get PreferredHeight() : int;

Property Value

The preferred height of a single-line text box.

Remarks

The size returned by this property is based on the font height and border style of the text box. You can use this property to determine the appropriate size of the text box to ensure that text is properly displayed in the control. The value returned by this property is in pixels.

Example [Visual Basic]

The following example uses TextBox, a derived class, to create a text box that can properly display text using a 20 point Arial font with a single border. This example uses the PreferredHeight property to determine the appropriate height of the control after the font and BorderStyle have been assigned.

[Visual Basic]

Public Sub CreateTextBox()
   ' Create an instance of the TextBox control.
   Dim Text1 as TextBox
   Set Text1 = New TextBox
   ' Set the TextBox Font property to 20 point Arial.
   Set Text1.Font = New Font ("Arial" , 20)
   ' Set the BorderStyle property to FixedSingle.
   Text1.BorderStyle = BorderStyle.FixedSingle
   ' Make the height of the control equal to the preferred height.
   Text1.Height = Text1.PreferredHeight
End Sub

See Also

TextBoxBase Class | TextBoxBase Members | System.WinForms Namespace | AutoSize