Export (0) Print
Expand All

DomainUpDown.DomainUpDownItemCollection Class

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

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

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

public class DomainUpDownItemCollection : ArrayList

The DomainUpDown.DomainUpDownItemCollection type exposes the following members.

  NameDescription
Public propertyCapacityGets or sets the number of elements that the ArrayList can contain. (Inherited from ArrayList.)
Public propertyCountGets the number of elements actually contained in the ArrayList. (Inherited from ArrayList.)
Public propertyIsFixedSizeGets a value indicating whether the ArrayList has a fixed size. (Inherited from ArrayList.)
Public propertyIsReadOnlyGets a value indicating whether the ArrayList is read-only. (Inherited from ArrayList.)
Public propertyIsSynchronizedGets a value indicating whether access to the ArrayList is synchronized (thread safe). (Inherited from ArrayList.)
Public propertyItemGets or sets the item at the specified indexed location in the collection. (Overrides ArrayList.Item[Int32].)
Public propertySyncRootGets an object that can be used to synchronize access to the ArrayList. (Inherited from ArrayList.)
Top

  NameDescription
Public methodAddAdds the specified object to the end of the collection. (Overrides ArrayList.Add(Object).)
Public methodAddRangeAdds the elements of an ICollection to the end of the ArrayList. (Inherited from ArrayList.)
Public methodBinarySearch(Object)Searches the entire sorted ArrayList for an element using the default comparer and returns the zero-based index of the element. (Inherited from ArrayList.)
Public methodBinarySearch(Object, IComparer)Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element. (Inherited from ArrayList.)
Public methodBinarySearch(Int32, Int32, Object, IComparer)Searches a range of elements in the sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element. (Inherited from ArrayList.)
Public methodClearRemoves all elements from the ArrayList. (Inherited from ArrayList.)
Public methodCloneCreates a shallow copy of the ArrayList. (Inherited from ArrayList.)
Public methodContainsDetermines whether an element is in the ArrayList. (Inherited from ArrayList.)
Public methodCopyTo(Array)Copies the entire ArrayList to a compatible one-dimensional Array, starting at the beginning of the target array. (Inherited from ArrayList.)
Public methodCopyTo(Array, Int32)Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ArrayList.)
Public methodCopyTo(Int32, Array, Int32, Int32)Copies a range of elements from the ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ArrayList.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumerator()Returns an enumerator for the entire ArrayList. (Inherited from ArrayList.)
Public methodGetEnumerator(Int32, Int32)Returns an enumerator for a range of elements in the ArrayList. (Inherited from ArrayList.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetRangeReturns an ArrayList which represents a subset of the elements in the source ArrayList. (Inherited from ArrayList.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOf(Object)Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList. (Inherited from ArrayList.)
Public methodIndexOf(Object, Int32)Searches for the specified Object and returns the zero-based index of the first occurrence within the range of elements in the ArrayList that extends from the specified index to the last element. (Inherited from ArrayList.)
Public methodIndexOf(Object, Int32, Int32)Searches for the specified Object and returns the zero-based index of the first occurrence within the range of elements in the ArrayList that starts at the specified index and contains the specified number of elements. (Inherited from ArrayList.)
Public methodInsertInserts the specified object into the collection at the specified location. (Overrides ArrayList.Insert(Int32, Object).)
Public methodInsertRangeInserts the elements of a collection into the ArrayList at the specified index. (Inherited from ArrayList.)
Public methodLastIndexOf(Object)Searches for the specified Object and returns the zero-based index of the last occurrence within the entire ArrayList. (Inherited from ArrayList.)
Public methodLastIndexOf(Object, Int32)Searches for the specified Object and returns the zero-based index of the last occurrence within the range of elements in the ArrayList that extends from the first element to the specified index. (Inherited from ArrayList.)
Public methodLastIndexOf(Object, Int32, Int32)Searches for the specified Object and returns the zero-based index of the last occurrence within the range of elements in the ArrayList that contains the specified number of elements and ends at the specified index. (Inherited from ArrayList.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the specified item from the collection. (Overrides ArrayList.Remove(Object).)
Public methodRemoveAtRemoves the item from the specified location in the collection. (Overrides ArrayList.RemoveAt(Int32).)
Public methodRemoveRangeRemoves a range of elements from the ArrayList. (Inherited from ArrayList.)
Public methodReverse()Reverses the order of the elements in the entire ArrayList. (Inherited from ArrayList.)
Public methodReverse(Int32, Int32)Reverses the order of the elements in the specified range. (Inherited from ArrayList.)
Public methodSetRangeCopies the elements of a collection over a range of elements in the ArrayList. (Inherited from ArrayList.)
Public methodSort()Sorts the elements in the entire ArrayList. (Inherited from ArrayList.)
Public methodSort(IComparer)Sorts the elements in the entire ArrayList using the specified comparer. (Inherited from ArrayList.)
Public methodSort(Int32, Int32, IComparer)Sorts the elements in a range of elements in ArrayList using the specified comparer. (Inherited from ArrayList.)
Public methodToArray()Copies the elements of the ArrayList to a new Object array. (Inherited from ArrayList.)
Public methodToArray(Type)Copies the elements of the ArrayList to a new array of the specified element type. (Inherited from ArrayList.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTrimToSizeSets the capacity to the actual number of elements in the ArrayList. (Inherited from ArrayList.)
Top

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());
 }



.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

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

Community Additions

ADD
Show:
© 2014 Microsoft