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!

UpDownBase.PreferredHeight

Gets the height of the up-down control.

[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 height of the up-down control in pixels.

Remarks

The PreferredHeight property value is based upon the System.WinForms.TextBox.PreferredHeight property of the text box portion of the control and is adjusted for the style of border.

Example [Visual Basic]

The following example uses the derived class, NumericUpDown. This code assumes you have a NumericUpDown control and a Button instantiated on a form. On the System.WinForms.Control.Click of the button, the point size of text in the NumericUpDown control increases. This will prompt the control to adjust its PreferredHeight property so all of the text is visible in the control. As the user types in a new value in the NumericUpDown control, the text is converted to a numeric value from a string value and validated to be between the System.WinForms.UpDownBase.Minimum and System.WinForms.UpDownBase.Maximum values. If the value is not valid, the Select method will select the text so the user can enter new a new value.

[Visual Basic]

Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs)
   ' If the entered value is greater than Minimum or Maximum, 
   ' select the text and open a message box.
   If CInt(NumericUpDown1.Text) > NumericUpDown1.Maximum Or _
     CInt(NumericUpDown1.Text) < NumericUpDown1.Minimum Then
      NumericUpDown1.Select 0, Len(NumericUpDown1.Text)
      MsgBox "The value entered was not between the Minimum and Maximum allowable values." _
       & vbCrLf & "Please re-enter.", , "Invalid Value"
   End If
    
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs)
   Dim varPrefHeight1 As Integer
   Dim varPrefHeight2 As Integer

   ' Capture the PreferredHeight in variables before and after 
   ' the Font is changed, display the results in a message box.
   varPrefHeight1 = NumericUpDown1.PreferredHeight
   Set NumericUpDown1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12!, _
     System.Drawing.FontSize.Points, System.Drawing.FontWeight.Bold, False, False, _
     False, System.Drawing.CharacterSet.Default, 0)
   varPrefHeight2 = NumericUpDown1.PreferredHeight
    
   MsgBox "Before Font Change: " & varPrefHeight1 & "After Font Change: " _
     & varPrefHeight2, , "Preferred Height"

End Sub

See Also

UpDownBase Class | UpDownBase Members | System.WinForms Namespace | System.WinForms.TextBox.PreferredHeight