UpDownBase.ReadOnly プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

/** @property */ public boolean get_ReadOnly () /** @property */ public void set_ReadOnly (boolean value)
上向きの矢印ボタンまたは下向きの矢印ボタンを使用するときにだけテキストを変更できる場合は true。それ以外の場合は false。既定値は false です。

ReadOnly プロパティを true に設定すると、Text プロパティの多数の検証を行う必要がなくなります。Text 値を変更する場合、ユーザーは上向きの矢印ボタンと下向きの矢印ボタンだけ使用できます。したがって、ユーザーは指定された値だけを選択できます。
![]() |
---|
派生クラスの DomainUpDown では、説明されている動作が若干異なります。ReadOnly が true に設定され、キーが押されている場合、コントロールでは、先頭の文字が押されたキーと一致する、コレクション内の最初の項目が選択されます。 |

派生クラス NumericUpDown を使用して、UpDownBase から派生したこのクラスのプロパティの一部を設定するコード例を次に示します。このコードは、NumericUpDown コントロール、2 つの ComboBox コントロール、および 3 つの CheckBox コントロールがフォーム上で作成されていることを前提にしています。ComboBox コントロールの BorderStyle および TextAlign にラベルを付けます。CheckBox コントロールの InterceptArrowKeys、ReadOnly、および UpDownAlign にラベルを付けます。このコードを使用すると、実行時にプロパティ値を変更したり、それぞれの変更がスピン ボックスの外観と動作にどのように影響するかを確認したりできます。BorderStyle というラベルのコンボ ボックスに、None、Fixed3D、FixedSingle の各項目を追加します。TextAlign というラベルのコンボ ボックスに、Left、Right、Center の各項目を追加します。
Private Sub comboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) ' Set the BorderStyle property. Select Case comboBox1.Text Case "Fixed3D" numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Case "None" numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.None Case "FixedSingle" numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle End Select End Sub Private Sub comboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) ' Set the TextAlign property. Select Case comboBox2.Text Case "Right" numericUpDown1.TextAlign = HorizontalAlignment.Right Case "Left" numericUpDown1.TextAlign = HorizontalAlignment.Left Case "Center" numericUpDown1.TextAlign = HorizontalAlignment.Center End Select End Sub Private Sub checkBox1_Click(sender As Object, e As EventArgs) ' Evaluate and toggle the ReadOnly property. If numericUpDown1.ReadOnly Then numericUpDown1.ReadOnly = False Else numericUpDown1.ReadOnly = True End If End Sub Private Sub checkBox2_Click(sender As Object, e As EventArgs) ' Evaluate and toggle the InterceptArrowKeys property. If numericUpDown1.InterceptArrowKeys Then numericUpDown1.InterceptArrowKeys = False Else numericUpDown1.InterceptArrowKeys = True End If End Sub Private Sub checkBox3_Click(sender As Object, e As EventArgs) ' Evaluate and toggle the UpDownAlign property. If numericUpDown1.UpDownAlign = LeftRightAlignment.Left Then numericUpDown1.UpDownAlign = LeftRightAlignment.Right Else numericUpDown1.UpDownAlign = LeftRightAlignment.Left End If End Sub
private void comboBox1_SelectedIndexChanged(Object sender, EventArgs e) { // Set the BorderStyle property. switch(comboBox1.Text) { case "Fixed3D": numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; break; case "None": numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.None; break; case "FixedSingle": numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; break; } } private void comboBox2_SelectedIndexChanged(Object sender, EventArgs e) { // Set the TextAlign property. switch (comboBox2.Text) { case "Right": numericUpDown1.TextAlign = HorizontalAlignment.Right; break; case "Left": numericUpDown1.TextAlign = HorizontalAlignment.Left; break; case "Center": numericUpDown1.TextAlign = HorizontalAlignment.Center; break; } } private void checkBox1_Click(Object sender, EventArgs e) { // Evaluate and toggle the ReadOnly property. if (numericUpDown1.ReadOnly) { numericUpDown1.ReadOnly = false; } else { numericUpDown1.ReadOnly = true; } } private void checkBox2_Click(Object sender, EventArgs e) { // Evaluate and toggle the InterceptArrowKeys property. if (numericUpDown1.InterceptArrowKeys) { numericUpDown1.InterceptArrowKeys = false; } else { numericUpDown1.InterceptArrowKeys = true; } } private void checkBox3_Click(Object sender, EventArgs e) { // Evaluate and toggle the UpDownAlign property. if (numericUpDown1.UpDownAlign == LeftRightAlignment.Left) { numericUpDown1.UpDownAlign = LeftRightAlignment.Right; } else { numericUpDown1.UpDownAlign = LeftRightAlignment.Left; } }
void comboBox1_SelectedIndexChanged( Object^ sender, EventArgs^ e ) { // Set the BorderStyle property. if ( !String::Compare( comboBox1->Text, "Fixed3D" ) ) { numericUpDown1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D; } else if ( !String::Compare( comboBox1->Text, "None" ) ) { numericUpDown1->BorderStyle = System::Windows::Forms::BorderStyle::None; } else if ( !String::Compare( comboBox1->Text, "FixedSingle" ) ) { numericUpDown1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; } } void comboBox2_SelectedIndexChanged( Object^ sender, EventArgs^ e ) { // Set the TextAlign property. if ( !String::Compare( comboBox2->Text, "Right" ) ) { numericUpDown1->TextAlign = HorizontalAlignment::Right; } else if ( !String::Compare( comboBox1->Text, "Left" ) ) { numericUpDown1->TextAlign = HorizontalAlignment::Left; } else if ( !String::Compare( comboBox1->Text, "Center" ) ) { numericUpDown1->TextAlign = HorizontalAlignment::Center; } } void checkBox1_Click( Object^ sender, EventArgs^ e ) { // Evaluate and toggle the ReadOnly property. if ( numericUpDown1->ReadOnly ) { numericUpDown1->ReadOnly = false; } else { numericUpDown1->ReadOnly = true; } } void checkBox2_Click( Object^ sender, EventArgs^ e ) { // Evaluate and toggle the InterceptArrowKeys property. if ( numericUpDown1->InterceptArrowKeys ) { numericUpDown1->InterceptArrowKeys = false; } else { numericUpDown1->InterceptArrowKeys = true; } } void checkBox3_Click( Object^ sender, EventArgs^ e ) { // Evaluate and toggle the UpDownAlign property. if ( numericUpDown1->UpDownAlign == LeftRightAlignment::Left ) { numericUpDown1->UpDownAlign = LeftRightAlignment::Right; } else { numericUpDown1->UpDownAlign = LeftRightAlignment::Left; } }
private void comboBox1_SelectedIndexChanged(Object sender, EventArgs e) { // Set the BorderStyle property. if (comboBox1.get_Text().Equals("Fixed3D")) { numericUpDown1.set_BorderStyle(BorderStyle.Fixed3D); } else { if (comboBox1.get_Text().Equals("None")) { numericUpDown1.set_BorderStyle(BorderStyle.None); } else { if (comboBox1.get_Text().Equals("FixedSingle")) { numericUpDown1.set_BorderStyle(BorderStyle.FixedSingle); } } } }//comboBox1_SelectedIndexChanged private void comboBox2_SelectedIndexChanged(Object sender, EventArgs e) { // Set the TextAlign property. if (comboBox2.get_Text().Equals("Right")) { numericUpDown1.set_TextAlign(HorizontalAlignment.Right); } else { if (comboBox2.get_Text().Equals("Left")) { numericUpDown1.set_TextAlign(HorizontalAlignment.Left); } else { if (comboBox2.get_Text().Equals("Center")) { numericUpDown1.set_TextAlign(HorizontalAlignment.Center); } } } } //comboBox2_SelectedIndexChanged private void checkBox1_Click(Object sender, EventArgs e) { // Evaluate and toggle the ReadOnly property. if (numericUpDown1.get_ReadOnly()) { numericUpDown1.set_ReadOnly(false); } else { numericUpDown1.set_ReadOnly(true); } } //checkBox1_Click private void checkBox2_Click(Object sender, EventArgs e) { // Evaluate and toggle the InterceptArrowKeys property. if (numericUpDown1.get_InterceptArrowKeys()) { numericUpDown1.set_InterceptArrowKeys(false); } else { numericUpDown1.set_InterceptArrowKeys(true); } } //checkBox2_Click private void checkBox3_Click(Object sender, EventArgs e) { // Evaluate and toggle the UpDownAlign property. if (numericUpDown1.get_UpDownAlign().Equals(LeftRightAlignment.Left)) { numericUpDown1.set_UpDownAlign(LeftRightAlignment.Right); } else { numericUpDown1.set_UpDownAlign(LeftRightAlignment.Left ); } } //checkBox3_Click } //Form1

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からUpDownBase.ReadOnly プロパティを検索する場合は、下記のリンクをクリックしてください。

- UpDownBase.ReadOnly プロパティのページへのリンク