다음을 통해 공유


DomainUpDown 클래스

문자열 값을 표시하는 Windows 스핀 상자(up-down 컨트롤이라고도 함)를 나타냅니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class DomainUpDown
    Inherits UpDownBase
‘사용 방법
Dim instance As DomainUpDown
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class DomainUpDown : UpDownBase
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class DomainUpDown : public UpDownBase
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class DomainUpDown extends UpDownBase
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class DomainUpDown extends UpDownBase

설명

DomainUpDown 컨트롤은 컨트롤의 위쪽 또는 아래쪽 단추를 클릭하여 Object 컬렉션에서 선택한 단일 문자열 값을 표시합니다. ReadOnly 속성을 true로 설정하지 않은 경우 사용자가 컨트롤에 텍스트를 입력할 수 있습니다. 입력한 문자열은 컬렉션에 들어 있는 항목과 일치해야 합니다. 항목을 선택하면 스핀 상자에 표시할 수 있도록 개체가 문자열 값으로 변환됩니다.

DomainUpDown 컨트롤에 표시할 개체 컬렉션을 만들려면 AddRemove 메서드를 사용하여 항목을 개별적으로 추가하거나 제거하면 됩니다. 이 메서드는 단추의 Click 이벤트와 같은 이벤트 처리기에서 호출될 수 있습니다. Sorted 속성을 true로 설정하여 개체 컬렉션을 사전순으로 정렬할 수도 있습니다. Wrap 속성이 true로 설정된 경우 컬렉션에 있는 마지막 또는 첫 번째 개체를 지나서 스크롤하면 목록이 첫 번째 또는 마지막 개체부터 다시 시작되어 연속 목록에서 스크롤하는 것처럼 보입니다.

코드를 사용하거나 위쪽 또는 아래쪽 단추를 클릭해서 UpButton 또는 DownButton 메서드를 호출하면 UpdateEditText를 호출하여 컨트롤을 새 문자열로 업데이트합니다. UserEdittrue로 설정되면 컨트롤의 텍스트 표시가 업데이트되기 전에 문자열이 컬렉션에 있는 값 중 하나와 일치됩니다.

예제

다음 코드 예제에서는 DomainUpDown 컨트롤을 만든 다음 초기화합니다. 이 예제에서 해당 속성 중 일부를 설정하고 스핀 상자에 표시할 문자열 컬렉션을 만들 수 있습니다. 이 코드는 TextBox, CheckBoxButton이 폼에 인스턴스화되었다고 가정합니다. 또한 이 예제에서는 사용자가 myCounter라는 32비트 부호 있는 정수로 선언된 클래스 수준에서 멤버 변수를 가지고 있다고 가정합니다. 입력란에 문자열을 입력한 다음 해당 단추를 클릭하여 Items 컬렉션에 추가할 수 있습니다. 확인란을 클릭하면 Sorted 속성을 설정하거나 해제하고 스핀 상자에 있는 항목 컬렉션에서 차이점을 관찰할 수 있습니다.

Protected domainUpDown1 As DomainUpDown


Private Sub MySub()
    ' Create and initialize the DomainUpDown control.
    domainUpDown1 = New System.Windows.Forms.DomainUpDown()
    
    ' Add the DomainUpDown control to the form.
    Controls.Add(domainUpDown1)
End Sub 'MySub


Private Sub button1_Click(sender As System.Object, e As System.EventArgs)
    ' Add the text box contents and initial location in the collection
    ' to the DomainUpDown control.
    domainUpDown1.Items.Add((textBox1.Text.Trim() & " - " & myCounter))
    
    ' Increment the counter variable.
    myCounter = myCounter + 1
    
    ' Clear the TextBox.
    textBox1.Text = ""
End Sub 'button1_Click


Private Sub checkBox1_Click(sender As System.Object, e As System.EventArgs)
    ' If Sorted is set to true, set it to false; 
    ' otherwise set it to true.
    If domainUpDown1.Sorted Then
        domainUpDown1.Sorted = False
    Else
        domainUpDown1.Sorted = True
    End If
End Sub 'checkBox1_Click


Private Sub domainUpDown1_SelectedItemChanged _
    (sender As System.Object, e As System.EventArgs)
    
    ' Display the SelectedIndex and SelectedItem property values in a MessageBox.
    MessageBox.Show(("SelectedIndex: " & domainUpDown1.SelectedIndex.ToString() & _
        ControlChars.Cr & "SelectedItem: " & domainUpDown1.SelectedItem.ToString()))
End Sub 'domainUpDown1_SelectedItemChanged
protected DomainUpDown domainUpDown1;

private void MySub()
 {
    // Create and initialize the DomainUpDown control.
    domainUpDown1 = new System.Windows.Forms.DomainUpDown();
    
    // Add the DomainUpDown control to the form.
    Controls.Add(domainUpDown1);
 }
 
 private void button1_Click(System.Object sender, 
                           System.EventArgs e)
 {   
    // Add the text box contents and initial location in the collection
    // to the DomainUpDown control.
    domainUpDown1.Items.Add((textBox1.Text.Trim()) + " - " + myCounter);
    
    // Increment the counter variable.
    myCounter = myCounter + 1;
 
    // Clear the TextBox.
    textBox1.Text = "";
 }
 
 private void checkBox1_Click(System.Object sender, 
                             System.EventArgs e)
 {
    // If Sorted is set to true, set it to false; 
    // otherwise set it to true.
    if (domainUpDown1.Sorted)
    {
       domainUpDown1.Sorted = false;
    }
    else
    {
       domainUpDown1.Sorted = true;
    }
 }
 
 private void domainUpDown1_SelectedItemChanged(System.Object sender, 
                                               System.EventArgs e)
 {
    // Display the SelectedIndex and SelectedItem property values in a MessageBox.
    MessageBox.Show("SelectedIndex: " + domainUpDown1.SelectedIndex.ToString() 
       + "\n" + "SelectedItem: " + domainUpDown1.SelectedItem.ToString());
 }
protected:
   DomainUpDown^ domainUpDown1;

private:
   void MySub()
   {
      // Create and initialize the DomainUpDown control.
      domainUpDown1 = gcnew System::Windows::Forms::DomainUpDown;
      
      // Add the DomainUpDown control to the form.
      Controls->Add( domainUpDown1 );
   }

   void button1_Click( System::Object^ sender,
     System::EventArgs^ e )
   {
      // Add the text box contents and initial location in the collection
      // to the DomainUpDown control.
      domainUpDown1->Items->Add( String::Concat(
         (textBox1->Text->Trim()), " - ", myCounter.ToString() ) );
      
      // Increment the counter variable.
      myCounter = myCounter + 1;
      
      // Clear the TextBox.
      textBox1->Text = "";
   }

   void checkBox1_Click( Object^ sender, EventArgs^ e )
   {
      // If Sorted is set to true, set it to false; 
      // otherwise set it to true.
      if ( domainUpDown1->Sorted )
      {
         domainUpDown1->Sorted = false;
      }
      else
      {
         domainUpDown1->Sorted = true;
      }
   }

   void domainUpDown1_SelectedItemChanged( Object^ sender, EventArgs^ e )
   {
      // Display the SelectedIndex and SelectedItem property values in a MessageBox.
      MessageBox::Show( String::Concat( "SelectedIndex: ",
      domainUpDown1->SelectedIndex.ToString(), "\n", "SelectedItem: ",
      domainUpDown1->SelectedItem->ToString() ) );
   }
protected DomainUpDown domainUpDown1;

private void MySub()
{
    // Create and initialize the DomainUpDown control.
    domainUpDown1 = new System.Windows.Forms.DomainUpDown();

    // Add the DomainUpDown control to the form.
    get_Controls().Add(domainUpDown1);
} //MySub

private void button1_Click(Object sender, System.EventArgs e)
{
    // Add the text box contents and initial location in the collection
    // to the DomainUpDown control.
    domainUpDown1.get_Items().Add((textBox1.get_Text().Trim() 
        + " - " + myCounter));

    // Increment the counter variable.
    myCounter = myCounter + 1;

    // Clear the TextBox.
    textBox1.set_Text("");
} //button1_Click

private void checkBox1_Click(Object sender, System.EventArgs e)
{
    // If Sorted is set to true, set it to false; 
    // otherwise set it to true.
    if (domainUpDown1.get_Sorted()) {
        domainUpDown1.set_Sorted(false);
    }
    else {
        domainUpDown1.set_Sorted(true);
    }
} //checkBox1_Click

private void domainUpDown1_SelectedItemChanged(Object sender, 
    System.EventArgs e)
{
    // Display the SelectedIndex and SelectedItem property values in a 
    // MessageBox.
    MessageBox.Show(("SelectedIndex: " 
        + System.Convert.ToString(domainUpDown1.get_SelectedIndex()) 
        + "\n" + "SelectedItem: " 
        + System.Convert.ToString(domainUpDown1.get_SelectedItem())));
} //domainUpDown1_SelectedItemChanged

상속 계층 구조

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

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

DomainUpDown 멤버
System.Windows.Forms 네임스페이스
UpDownBase
NumericUpDown