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.ReadOnly

Gets or sets a value indicating whether the text may only be changed by the use of the up or down buttons.

[Visual Basic]
Public Property ReadOnly As Boolean
[C#]
public bool ReadOnly {get; set;}
[C++]
public: __property bool get_ReadOnly();
public: __property void set_ReadOnly(bool);
[JScript]
public function get ReadOnly() : Boolean;
public function set ReadOnly(Boolean);

Property Value

true if the text may only be changed by the use of the up or down buttons; otherwise, false. The default value is false.

Remarks

By setting the ReadOnly property to true, you will eliminate the need for much validation of the Text property. The user will be restricted to the use of the up and down buttons to change the Text values. It will only allow them to select values you specify.

Example [Visual Basic]

The following example uses the derived class, NumericUpDown and sets some of its properties derived from UpDownBase. This code assumes you have a NumericUpDown control, two ComboBox controls and three CheckBox controls instantiated on a form. The ComboBox controls should be labeled: BorderStyle and TextAlign. See the table below for the appropriate values to be added to the ComboBox controls. The CheckBox controls should be labled: InterceptArrowKeys, ReadOnly and, UpDownAlign- Left. The code will allow you to change the property values at run-time and see how each effect the appearance or behavior of the up-down control.

BorderStyle TextAlign
None Left
Fixed3D Right
FixedSingle Center

[Visual Basic]

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
     ' Set the TextAlign property.    
    Select Case ComboBox2.Text
        Case "Right"
NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Right
        Case "Left"
NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Left
        Case "Center"
NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Center
    End Select
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
     ' Set the BorderStyle property.
    Select Case ComboBox1.Text
        Case "Fixed3D"
NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.Fixed3D
        Case "None"
NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.None
        Case "FixedSingle"
NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.FixedSingle
    End Select
End Sub

Private Sub CheckBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
     ' Evaluate and toggle the UpDownAlign property.
    If NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Left Then
        NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Right
    Else
        NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Left
    End If
End Sub

Private Sub CheckBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
     ' Evaluate and toggle the InterceptArrowKeys property.
    If NumericUpDown1.InterceptArrowKeys = True Then
        NumericUpDown1.InterceptArrowKeys = False
    Else
        NumericUpDown1.InterceptArrowKeys = True
    End If
End Sub

Private Sub CheckBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
     ' Evaluate and toggle the ReadOnly property.
    If NumericUpDown1.ReadOnly = True Then
        NumericUpDown1.ReadOnly = False
    Else
        NumericUpDown1.ReadOnly = True
    End If
End Sub

See Also

UpDownBase Class | UpDownBase Members | System.WinForms Namespace | Text