DomainUpDown.DomainUpDownItemCollection DomainUpDown.DomainUpDownItemCollection DomainUpDown.DomainUpDownItemCollection DomainUpDown.DomainUpDownItemCollection Class

定义

封装一个对象集合供 DomainUpDown 类使用。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
继承
DomainUpDown.DomainUpDownItemCollectionDomainUpDown.DomainUpDownItemCollectionDomainUpDown.DomainUpDownItemCollectionDomainUpDown.DomainUpDownItemCollection

示例

以下示例创建并初始化DomainUpDown控件。The following example creates and initializes a DomainUpDown control. 该示例可以设置它的一些属性并创建 up-down 控件中显示的字符串的集合。The example allows you to set some of its properties and create a collection of strings for display in the up-down control. 该代码假定TextBoxCheckBox和一个Button已实例化窗体上。The code assumes that a TextBox, CheckBox and a Button have been instantiated on a form. 该示例还假定你已在类级别声明名为 32 位有符号整数的一个成员变量myCounterThe example also assumes that you have a member variable at the class level declared as a 32-bit signed integer named myCounter. 可以在文本框中输入一个字符串,并将其添加到Items集合时单击该按钮。You can enter a string in the text box and add it to the Items collection when the button is clicked. 通过单击复选框,您可以切换Sorted属性,并观察 up-down 控件中的项集合中的差异。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 'InitializeMyDomainUpDown


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 'button1_Click


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 'checkBox1_Click


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 'domainUpDown1_SelectedItemChanged

注解

若要创建的对象中显示的集合DomainUpDown控件,可以添加或删除的项分别通过使用AddRemove方法。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. 从父控件访问集合DomainUpDown,也可由Items属性。The collection is accessed from the parent control, DomainUpDown, by the Items property.

属性

Capacity Capacity Capacity Capacity

获取或设置 ArrayList 可包含的元素数。Gets or sets the number of elements that the ArrayList can contain.

(Inherited from ArrayList)
Count Count Count Count

获取 ArrayList 中实际包含的元素数。Gets the number of elements actually contained in the ArrayList.

(Inherited from ArrayList)
IsFixedSize IsFixedSize IsFixedSize IsFixedSize

获取一个值,该值指示 ArrayList 是否具有固定大小。Gets a value indicating whether the ArrayList has a fixed size.

(Inherited from ArrayList)
IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示 ArrayList 是否为只读。Gets a value indicating whether the ArrayList is read-only.

(Inherited from ArrayList)
IsSynchronized IsSynchronized IsSynchronized IsSynchronized

获取一个值,该值指示是否同步对 ArrayList 的访问(线程安全)。Gets a value indicating whether access to the ArrayList is synchronized (thread safe).

(Inherited from ArrayList)
Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取或设置集合中指定索引位置处的项。Gets or sets the item at the specified indexed location in the collection.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步对 ArrayList 的访问的对象。Gets an object that can be used to synchronize access to the ArrayList.

(Inherited from ArrayList)

方法

Add(Object) Add(Object) Add(Object) Add(Object)

将指定的对象添加到集合末尾。Adds the specified object to the end of the collection.

AddRange(ICollection) AddRange(ICollection) AddRange(ICollection) AddRange(ICollection)

ICollection 的元素添加到 ArrayList 的末尾。Adds the elements of an ICollection to the end of the ArrayList.

(Inherited from ArrayList)
BinarySearch(Int32, Int32, Object, IComparer) BinarySearch(Int32, Int32, Object, IComparer) BinarySearch(Int32, Int32, Object, IComparer) BinarySearch(Int32, Int32, Object, IComparer)

使用指定的比较器在已排序 ArrayList 的某个元素范围中搜索元素,并返回该元素从零开始的索引。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) BinarySearch(Object) BinarySearch(Object) BinarySearch(Object)

使用默认的比较器在整个已排序的 ArrayList 中搜索元素,并返回该元素从零开始的索引。Searches the entire sorted ArrayList for an element using the default comparer and returns the zero-based index of the element.

(Inherited from ArrayList)
BinarySearch(Object, IComparer) BinarySearch(Object, IComparer) BinarySearch(Object, IComparer) BinarySearch(Object, IComparer)

使用指定的比较器在整个已排序的 ArrayList 中搜索元素,并返回该元素从零开始的索引。Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element.

(Inherited from ArrayList)
Clear() Clear() Clear() Clear()

ArrayList 中移除所有元素。Removes all elements from the ArrayList.

(Inherited from ArrayList)
Clone() Clone() Clone() Clone()

创建 ArrayList 的浅表副本。Creates a shallow copy of the ArrayList.

(Inherited from ArrayList)
Contains(Object) Contains(Object) Contains(Object) Contains(Object)

确定某元素是否在 ArrayList 中。Determines whether an element is in the ArrayList.

(Inherited from ArrayList)
CopyTo(Array) CopyTo(Array) CopyTo(Array) CopyTo(Array)

从目标数组的开头开始,将整个 ArrayList 复制到兼容的一维 ArrayCopies the entire ArrayList to a compatible one-dimensional Array, starting at the beginning of the target array.

(Inherited from ArrayList)
CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 ArrayList 复制到兼容的一维 ArrayCopies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array.

(Inherited from ArrayList)
CopyTo(Int32, Array, Int32, Int32) CopyTo(Int32, Array, Int32, Int32) CopyTo(Int32, Array, Int32, Int32) CopyTo(Int32, Array, Int32, Int32)

从目标数组的指定索引处开始,将 ArrayList 中某个范围的元素复制到兼容的一维数组 ArrayCopies 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) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回用于整个 ArrayList 的枚举数。Returns an enumerator for the entire ArrayList.

(Inherited from ArrayList)
GetEnumerator(Int32, Int32) GetEnumerator(Int32, Int32) GetEnumerator(Int32, Int32) GetEnumerator(Int32, Int32)

返回 ArrayList 中元素范围的枚举器。Returns an enumerator for a range of elements in the ArrayList.

(Inherited from ArrayList)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetRange(Int32, Int32) GetRange(Int32, Int32) GetRange(Int32, Int32) GetRange(Int32, Int32)

返回一个 ArrayList,它表示源 ArrayList 中的元素子集。Returns an ArrayList which represents a subset of the elements in the source ArrayList.

(Inherited from ArrayList)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(Object) IndexOf(Object) IndexOf(Object) IndexOf(Object)

搜索指定的 Object,并返回整个 ArrayList 中第一个匹配项的从零开始的索引。Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList.

(Inherited from ArrayList)
IndexOf(Object, Int32) IndexOf(Object, Int32) IndexOf(Object, Int32) IndexOf(Object, Int32)

搜索指定的 Object,并返回 ArrayList 中从指定索引到最后一个元素的元素范围中第一个匹配项的从零开始索引。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, Int32, Int32) IndexOf(Object, Int32, Int32) IndexOf(Object, Int32, Int32) IndexOf(Object, Int32, Int32)

搜索指定的 Object,并返回 ArrayList 中从指定索引开始,并包含指定元素数的元素范围中第一个匹配项的从零开始的索引。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)
Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object)

将指定的对象插入到指定位置处的集合中。Inserts the specified object into the collection at the specified location.

InsertRange(Int32, ICollection) InsertRange(Int32, ICollection) InsertRange(Int32, ICollection) InsertRange(Int32, ICollection)

将集合中的元素插入 ArrayList 的指定索引处。Inserts the elements of a collection into the ArrayList at the specified index.

(Inherited from ArrayList)
LastIndexOf(Object) LastIndexOf(Object) LastIndexOf(Object) LastIndexOf(Object)

在整个 ArrayList 中搜索指定的 Object,并返回最后一个匹配项的从零开始的索引。Searches for the specified Object and returns the zero-based index of the last occurrence within the entire ArrayList.

(Inherited from ArrayList)
LastIndexOf(Object, Int32) LastIndexOf(Object, Int32) LastIndexOf(Object, Int32) LastIndexOf(Object, Int32)

搜索指定的 Object,并返回 ArrayList 中从第一个元素到指定索引这部分元素中最后一个匹配项的从零开始索引。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, Int32, Int32) LastIndexOf(Object, Int32, Int32) LastIndexOf(Object, Int32, Int32) LastIndexOf(Object, Int32, Int32)

搜索指定的 Object,并返回 ArrayList 中到指定索引为止包含指定元素数的这部分元素中最后一个匹配项的从零开始的索引。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)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(Object) Remove(Object) Remove(Object) Remove(Object)

从集合中移除指定的项。Removes the specified item from the collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

从集合中的指定位置移除项。Removes the item from the specified location in the collection.

RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32)

ArrayList 中移除一定范围的元素。Removes a range of elements from the ArrayList.

(Inherited from ArrayList)
Reverse() Reverse() Reverse() Reverse()

将整个 ArrayList 中元素的顺序反转。Reverses the order of the elements in the entire ArrayList.

(Inherited from ArrayList)
Reverse(Int32, Int32) Reverse(Int32, Int32) Reverse(Int32, Int32) Reverse(Int32, Int32)

将指定范围中元素的顺序反转。Reverses the order of the elements in the specified range.

(Inherited from ArrayList)
SetRange(Int32, ICollection) SetRange(Int32, ICollection) SetRange(Int32, ICollection) SetRange(Int32, ICollection)

复制 ArrayList 中一个子集合的元素。Copies the elements of a collection over a range of elements in the ArrayList.

(Inherited from ArrayList)
Sort() Sort() Sort() Sort()

对整个 ArrayList 中的元素进行排序。Sorts the elements in the entire ArrayList.

(Inherited from ArrayList)
Sort(IComparer) Sort(IComparer) Sort(IComparer) Sort(IComparer)

使用指定的比较器对整个 ArrayList 中的元素进行排序。Sorts the elements in the entire ArrayList using the specified comparer.

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

使用指定的比较器对 ArrayList 中某个范围内的元素进行排序。Sorts the elements in a range of elements in ArrayList using the specified comparer.

(Inherited from ArrayList)
ToArray() ToArray() ToArray() ToArray()

ArrayList 的元素复制到新 Object 数组中。Copies the elements of the ArrayList to a new Object array.

(Inherited from ArrayList)
ToArray(Type) ToArray(Type) ToArray(Type) ToArray(Type)

ArrayList 的元素复制到新的指定元素类型数组中。Copies the elements of the ArrayList to a new array of the specified element type.

(Inherited from ArrayList)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
TrimToSize() TrimToSize() TrimToSize() TrimToSize()

将容量设置为 ArrayList 中元素的实际数目。Sets the capacity to the actual number of elements in the ArrayList.

(Inherited from ArrayList)

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

将转换IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅