UpDownBase.Text プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > UpDownBase.Text プロパティの意味・解説 

UpDownBase.Text プロパティ

スピン ボックス (アップダウン コントロール) に表示されるテキスト取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UpDownBase クラス
UpDownBase メンバ
System.Windows.Forms 名前空間
UserEdit
UpdateEditText
ValidateEditText


このページでは「.NET Framework クラス ライブラリ リファレンス」からUpDownBase.Text プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からUpDownBase.Text プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からUpDownBase.Text プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「UpDownBase.Text プロパティ」の関連用語

UpDownBase.Text プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



UpDownBase.Text プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS