Modifier

Partager via


DomainUpDown.DomainUpDownItemCollection Class

Definition

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

public: ref class DomainUpDown::DomainUpDownItemCollection : System::Collections::ArrayList
public class DomainUpDown.DomainUpDownItemCollection : System.Collections.ArrayList
type DomainUpDown.DomainUpDownItemCollection = class
    inherit ArrayList
Public Class DomainUpDown.DomainUpDownItemCollection
Inherits ArrayList
Inheritance
DomainUpDown.DomainUpDownItemCollection

Examples

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 = gcnew DomainUpDown;
      
      // Add the DomainUpDown control to the form.
      Controls->Add( domainUpDown1 );
   }

   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( String::Concat(
         (textBox1->Text->Trim()), " - ", myCounter ) );
      
      // 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.
      domainUpDown1->Sorted =  !domainUpDown1->Sorted;
   }

   void domainUpDown1_SelectedItemChanged( Object^ sender,
      EventArgs^ e )
   {
      
      // Display the SelectedIndex and 
      // SelectedItem property values in a MessageBox.
      MessageBox::Show( String::Concat( "SelectedIndex: ", domainUpDown1->SelectedIndex,
         "\nSelectedItem: ", domainUpDown1->SelectedItem ) );
   }
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());
 }
Protected domainUpDown1 As DomainUpDown


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


Private Sub button1_Click(sender As Object, e As 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


Private Sub checkBox1_Click(sender As Object, e As 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


Private Sub domainUpDown1_SelectedItemChanged _
    (sender As Object, e As 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

Remarks

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.

Properties

Capacity

Gets or sets the number of elements that the ArrayList can contain.

(Inherited from ArrayList)
Count

Gets the number of elements actually contained in the ArrayList.

(Inherited from ArrayList)
IsFixedSize

Gets a value indicating whether the ArrayList has a fixed size.

(Inherited from ArrayList)
IsReadOnly

Gets a value indicating whether the ArrayList is read-only.

(Inherited from ArrayList)
IsSynchronized

Gets a value indicating whether access to the ArrayList is synchronized (thread safe).

(Inherited from ArrayList)
Item[Int32]

Gets or sets the item at the specified indexed location in the collection.

SyncRoot

Gets an object that can be used to synchronize access to the ArrayList.

(Inherited from ArrayList)

Methods

Add(Object)

Adds the specified object to the end of the collection.

AddRange(ICollection)

Adds the elements of an ICollection to the end of the ArrayList.

(Inherited from ArrayList)
BinarySearch(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)
BinarySearch(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)
BinarySearch(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)
Clear()

Removes all elements from the ArrayList.

(Inherited from ArrayList)
Clone()

Creates a shallow copy of the ArrayList.

(Inherited from ArrayList)
Contains(Object)

Determines whether an element is in the ArrayList.

(Inherited from ArrayList)
CopyTo(Array, Int32)

Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array.

(Inherited from ArrayList)
CopyTo(Array)

Copies the entire ArrayList to a compatible one-dimensional Array, starting at the beginning of the target array.

(Inherited from ArrayList)
CopyTo(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)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Returns an enumerator for the entire ArrayList.

(Inherited from ArrayList)
GetEnumerator(Int32, Int32)

Returns an enumerator for a range of elements in the ArrayList.

(Inherited from ArrayList)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRange(Int32, Int32)

Returns an ArrayList which represents a subset of the elements in the source ArrayList.

(Inherited from ArrayList)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(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)
IndexOf(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)
IndexOf(Object)

Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList.

(Inherited from ArrayList)
Insert(Int32, Object)

Inserts the specified object into the collection at the specified location.

InsertRange(Int32, ICollection)

Inserts the elements of a collection into the ArrayList at the specified index.

(Inherited from ArrayList)
LastIndexOf(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)
LastIndexOf(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)
LastIndexOf(Object)

Searches for the specified Object and returns the zero-based index of the last occurrence within the entire ArrayList.

(Inherited from ArrayList)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(Object)

Removes the specified item from the collection.

RemoveAt(Int32)

Removes the item from the specified location in the collection.

RemoveRange(Int32, Int32)

Removes a range of elements from the ArrayList.

(Inherited from ArrayList)
Reverse()

Reverses the order of the elements in the entire ArrayList.

(Inherited from ArrayList)
Reverse(Int32, Int32)

Reverses the order of the elements in the specified range.

(Inherited from ArrayList)
SetRange(Int32, ICollection)

Copies the elements of a collection over a range of elements in the ArrayList.

(Inherited from ArrayList)
Sort()

Sorts the elements in the entire ArrayList.

(Inherited from ArrayList)
Sort(IComparer)

Sorts the elements in the entire ArrayList using the specified comparer.

(Inherited from ArrayList)
Sort(Int32, Int32, IComparer)

Sorts the elements in a range of elements in ArrayList using the specified comparer.

(Inherited from ArrayList)
ToArray()

Copies the elements of the ArrayList to a new Object array.

(Inherited from ArrayList)
ToArray(Type)

Copies the elements of the ArrayList to a new array of the specified element type.

(Inherited from ArrayList)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
TrimToSize()

Sets the capacity to the actual number of elements in the ArrayList.

(Inherited from ArrayList)

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also