DomainUpDown.Sorted 属性

获取或设置一个值,该值指示项集合是否排序。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property Sorted As Boolean
用法
Dim instance As DomainUpDown
Dim value As Boolean

value = instance.Sorted

instance.Sorted = value
public bool Sorted { get; set; }
public:
property bool Sorted {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_Sorted ()

/** @property */
public void set_Sorted (boolean value)
public function get Sorted () : boolean

public function set Sorted (value : boolean)

属性值

如果对项集合排序,则为 true;否则为 false。默认值为 false

备注

Sorted 设置为 true 时,将按字母顺序对集合排序。

示例

下面的代码示例创建并初始化一个 DomainUpDown 控件。该示例允许您设置它的部分属性并创建在数字显示框(也称为 up-down 控件)中显示的字符串集合。该代码假定已经在窗体上实例化了 TextBoxCheckBoxButton。示例还假定已将类级别上的一个成员变量声明为名为 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

平台

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

请参见

参考

DomainUpDown 类
DomainUpDown 成员
System.Windows.Forms 命名空间