UpDownBase クラスとは? わかりやすく解説

UpDownBase クラス

スピン ボックス (アップダウン コントロール) に必要な基本的な機能実装ます。

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

<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class
 UpDownBase
    Inherits ContainerControl
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public abstract class UpDownBase : ContainerControl
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class UpDownBase abstract : public
 ContainerControl
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public abstract class UpDownBase extends ContainerControl
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public abstract class UpDownBase extends
 ContainerControl
解説解説

スピン ボックスは、テキスト ボックス小さい垂直スクロール バー構成され一般的にはスピン ボタン コントロール呼ばれますUpDownBase クラスは、2 つコントロールリンクしてます。このクラス使用すると、ユーザー上向き矢印ボタンまたは下向き矢印ボタンクリックしてテキスト ボックス表示変更したり、テキスト ボックス適切な値を直接入力したりできますスピン ボックスは、リスト ボックスコンボ ボックス同様にユーザー選択できる値のリスト制限する場合使用します表示するリスト種類によっては、スピン ボックス使用すると、項目を一度1 つずつ追加せずに、有効な値の範囲簡単に設定できるという利点ありますUpDownBase からクラス派生するデータ型制限できるため、スピン ボックス実装は、テキスト ボックス実装よりもデータ検証数が少なくなります。たとえば、NumericUpDown クラスでは、値を数値型制限しMinimum プロパティMaximum プロパティ使用して値を検証します。

ユーザー方向キー使用してスピン ボックス内容変更できるようにするには、InterceptArrowKeys プロパティtrue設定します指定したに対してユーザー制限するには、ReadOnly プロパティtrue設定しますスピン ボックステキスト配置制御するには、TextAlign プロパティ設定しますコントロールテキスト ボックス部分関連する上向き矢印ボタン下向き矢印ボタンの配置設定するには、UpDownAlign プロパティLeft または Right設定します

UpButton メソッドおよび DownButton メソッドは、オーバーライドされるときに、上向き矢印ボタン下向き矢印ボタンクリック処理します。ValidateEditText メソッドおよび UpdateEditText メソッドは、オーバーライドされるときに、選択または入力された値を検証しスピン ボックス表示されるテキスト更新します。この値の検証失敗した場合は、Select メソッド使用して、有効ではないテキスト選択します。この場合ユーザー既存テキスト手動選択した削除したりせずに、新しい値を入力するだけでテキスト簡単に修正できます

継承時の注意 UpDownBase から継承する場合DownButtonUpButtonUpdateEditTextValidateEditText の各メンバオーバーライドする必要があります

使用例使用例

派生クラス NumericUpDown使用してUpDownBase から派生したこのクラスプロパティ一部設定するコード例次に示します。このコードでは、numericUpDown1 という名前の NumericUpDown コントロールcomboBox1 および comboBox2 という名前の 2 つComboBox コントロールcheckBox1checkBox2checkBox2 という名前の 3 つの CheckBox コントロールフォーム作成されていることを前提としています。comboBox1 には、NoneFixed3DFixedSingle という項目を追加しますcomboBox2 には、LeftRightCenter という項目を追加します

このコード使用すると、実行時プロパティ値を変更したり、それぞれの変更スピン ボックス外観動作どのように影響するかを確認したできます

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 
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.ContainerControl
            System.Windows.Forms.UpDownBase
               System.Windows.Forms.DomainUpDown
               System.Windows.Forms.NumericUpDown
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「UpDownBase クラス」の関連用語

UpDownBase クラスのお隣キーワード
検索ランキング

   

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



UpDownBase クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS