Export (0) Print
Expand All

DomainUpDown.DomainUpDownItemCollection Class

Encapsulates a collection of objects for use by the DomainUpDown class.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class DomainUpDownItemCollection : ArrayList

To create a collection of objects to display in the DomainUpDown control, you can add or remove the items individually by using the Add and Remove methods. The collection is accessed from the parent control, DomainUpDown, by the Items property.

The following 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 up-down control. The code assumes that a TextBox, CheckBox and a 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 up-down control.

protected DomainUpDown domainUpDown1;

private void InitializeMyDomainUpDown()
 {
    // Create and initialize the DomainUpDown control.
    domainUpDown1 = new DomainUpDown();

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

 private void button1_Click(Object sender, 
                           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(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;
    }
 }

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

System.Object
  System.Collections.ArrayList
    System.Windows.Forms.DomainUpDown.DomainUpDownItemCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft