Export (0) Print
Expand All

DomainUpDown.Sorted Property

Gets or sets a value indicating whether the item collection is sorted.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public bool Sorted { get; set; }
/** @property */
public boolean get_Sorted ()

/** @property */
public void set_Sorted (boolean value)

public function get Sorted () : boolean

public function set Sorted (value : boolean)

Not applicable.

Property Value

true if the item collection is sorted; otherwise, false. The default value is false.

When Sorted is set to true, the collection is sorted in alphabetical order.

The following code example creates and initializes a DomainUpDown control. The example allows you to set some of its properties and create a collection of strings for display in the spin box (also known as an up-down control). The code assumes that a TextBox, CheckBox, and Button have been instantiated on a form. The example also assumes that you have a member variable at the class level declared as a 32-bit signed integer named myCounter. You can enter a string in the text box and add it to the Items collection when the button is clicked. By clicking the check box, you can toggle the Sorted property and observe the difference in the collection of items in the spin box.

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 = 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 Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft