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

[LocalizableAttribute(true)] public: virtual property String^ Text { String^ get () override; void set (String^ value) override; }
スピン ボックスに表示される文字列値。

UpdateEditText メソッドは、UserEdit プロパティが true に設定されているときに、Text プロパティが設定されると呼び出されます。ValidateEditText メソッドは、UserEdit プロパティが false に設定されているときに、Text プロパティが設定されると呼び出されます。

派生クラス NumericUpDown を使用するコード例を次に示します。このコードは、NumericUpDown コントロールと Button がフォーム上に作成されていること、および System.Drawing 名前空間が参照として追加されていることを前提にしています。ボタンで Click イベントが発生すると、NumericUpDown コントロールのテキストのポイント数が増えます。ポイント数が増えると、コントロールにすべてのテキストを表示できるように、コントロールで PreferredHeight プロパティを調整するように促されます。ユーザーが新しい値を入力して NumericUpDown コントロールを終了すると、テキストが文字列値から数値へ変換され、Minimum 値と Maximum 値の間にあるかどうかが検証されます。値が無効な場合は、MessageBox にエラーが表示され、ユーザーが新しい値を入力できるように Select メソッドがテキストを選択します。
Private Sub numericUpDown1_Leave(sender As Object, e As EventArgs) ' If the entered value is greater than Minimum or Maximum, ' select the text and open a message box. If (System.Convert.ToInt32(numericUpDown1.Text) > numericUpDown1.Maximum) Or _ (System.Convert.ToInt32(numericUpDown1.Text) < numericUpDown1.Minimum) Then MessageBox.Show("The value entered was not between the Minimum and " & _ "Maximum allowable values." & Microsoft.VisualBasic.ControlChars.Cr & _ "Please re-enter.") numericUpDown1.Focus() numericUpDown1.Select(0, numericUpDown1.Text.Length) End If End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Dim varPrefHeight1 As Integer ' Capture the PreferredHeight before and after the Font ' is changed, and display the results in a message box. varPrefHeight1 = numericUpDown1.PreferredHeight numericUpDown1.Font = New System.Drawing.Font("Microsoft Sans Serif", _ 12F, System.Drawing.FontStyle.Bold) MessageBox.Show("Before Font Change: " & varPrefHeight1.ToString() & _ Microsoft.VisualBasic.ControlChars.Cr & "After Font Change: " & _ numericUpDown1.PreferredHeight.ToString()) End Sub
private void numericUpDown1_Leave(Object sender , EventArgs e) { /* If the entered value is greater than Minimum or Maximum, select the text and open a message box. */ if((System.Convert.ToInt32(numericUpDown1.Text) > numericUpDown1.Maximum) || (System.Convert.ToInt32(numericUpDown1.Text) < numericUpDown1.Minimum)) { MessageBox.Show("The value entered was not between the Minimum and" + "Maximum allowable values." + "\n" + "Please re-enter."); numericUpDown1.Focus(); numericUpDown1.Select(0, numericUpDown1.Text.Length); } } private void button1_Click(Object sender, EventArgs e) { int varPrefHeight1; /* Capture the PreferredHeight before and after the Font is changed, and display the results in a message box. */ varPrefHeight1 = numericUpDown1.PreferredHeight; numericUpDown1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold); MessageBox.Show("Before Font Change: " + varPrefHeight1.ToString() + "\n" + "After Font Change: " + numericUpDown1.PreferredHeight.ToString()); }
void numericUpDown1_Leave( Object^ /*sender*/, EventArgs^ /*e*/ ) { /* If the entered value is greater than Minimum or Maximum, select the text and open a message box. */ if ( (System::Convert::ToInt32( numericUpDown1->Text ) > numericUpDown1->Maximum) || (System::Convert::ToInt32( numericUpDown1->Text ) < numericUpDown1->Minimum) ) { MessageBox::Show( "The value entered was not between the Minimum andMaximum allowable values.\nPlease re-enter." ); numericUpDown1->Focus(); numericUpDown1->Select(0,numericUpDown1->Text->Length); } } void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ ) { int varPrefHeight1; /* Capture the PreferredHeight before and after the Font is changed, and display the results in a message box. */ varPrefHeight1 = numericUpDown1->PreferredHeight; numericUpDown1->Font = gcnew System::Drawing::Font( "Microsoft Sans Serif",12.0,System::Drawing::FontStyle::Bold ); MessageBox::Show( String::Format( "Before Font Change: {0}\nAfter Font Change: {1}", varPrefHeight1, numericUpDown1->PreferredHeight ) ); }
private void numericUpDown1_Leave(Object sender , EventArgs e) { /* If the entered value is greater than Minimum or Maximum, select the text and open a message box. */ if (System.Convert.ToInt32(numericUpDown1.get_Text()) > System.Convert.ToInt32(numericUpDown1.get_Maximum()) || System.Convert.ToInt32(numericUpDown1.get_Text()) < System.Convert.ToInt32(numericUpDown1.get_Minimum())) { MessageBox.Show(("The value entered was not between the Minimum and" + "Maximum allowable values." + "\n" + "Please re-enter.")); numericUpDown1.Focus(); numericUpDown1.Select(0, numericUpDown1.get_Text().length()); } } //NumericUpDown1_Leave private void button1_Click(Object sender, EventArgs e) { int varPrefHeight1; /* Capture the PreferredHeight before and after the Font is changed, and display the results in a message box. */ varPrefHeight1 = numericUpDown1.get_PreferredHeight(); numericUpDown1.set_Font( new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold)); MessageBox.Show(("Before Font Change: " + System.Convert.ToString(varPrefHeight1) + "\n" + "After Font Change: " + System.Convert.ToString( numericUpDown1.get_PreferredHeight()))); } //button1_Click

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.Text プロパティを検索する場合は、下記のリンクをクリックしてください。

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