DomainUpDown.DomainUpDownItemCollection 類別

定義

封裝物件的集合來提供 DomainUpDown 類別使用。

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.DomainUpDownItemCollection

範例

下列範例會建立並初始化 DomainUpDown 控制項。 此範例可讓您設定其部分屬性,並建立字串集合以顯示在上下控制項中。 程式碼假設 TextBox 已在表單上具現化 、 CheckBoxButton 。 此範例也假設您在類別層級宣告為名為 myCounter 的 32 位帶正負號整數的成員變數。 您可以在文字方塊中輸入字串,並在按一下按鈕時將其新增至 Items 集合。 按一下核取方塊,您可以切換 屬性, Sorted 並觀察向上控制項中專案集合的差異。

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

備註

若要建立要顯示在 控制項中的 DomainUpDown 物件集合,您可以使用 和 Remove 方法個別 Add 新增或移除專案。 集合是由 屬性從父控制項 DomainUpDown Items 存取。

屬性

Capacity

取得或設定 ArrayList 可包含的項目數目。

(繼承來源 ArrayList)
Count

取得 ArrayList 中實際包含的項目數目。

(繼承來源 ArrayList)
IsFixedSize

取得值,指出 ArrayList 是否有固定的大小。

(繼承來源 ArrayList)
IsReadOnly

取得值,指出 ArrayList 是否唯讀。

(繼承來源 ArrayList)
IsSynchronized

取得值,這個值表示對 ArrayList 的存取是否同步 (安全執行緒)。

(繼承來源 ArrayList)
Item[Int32]

取得或設定在集合的指定索引處的項目。

SyncRoot

取得可用以同步存取 ArrayList 的物件。

(繼承來源 ArrayList)

方法

Add(Object)

將指定的物件加入至集合的尾端。

AddRange(ICollection)

ICollection 的項目加入 ArrayList 的結尾。

(繼承來源 ArrayList)
BinarySearch(Int32, Int32, Object, IComparer)

使用指定的比較子在已經過排序之 ArrayList 內,搜尋某範圍的項目,並傳回該項目以零為起始的索引。

(繼承來源 ArrayList)
BinarySearch(Object)

使用預設的比較子並傳回項目以零為起始的索引,來搜尋項目之整個排序的 ArrayList

(繼承來源 ArrayList)
BinarySearch(Object, IComparer)

使用指定的比較子並傳回項目以零為起始的索引,來搜尋項目之整個排序的 ArrayList

(繼承來源 ArrayList)
Clear()

移除 ArrayList 中的所有項目。

(繼承來源 ArrayList)
Clone()

建立 ArrayList 的淺層複本。

(繼承來源 ArrayList)
Contains(Object)

判斷某項目是否在 ArrayList 中。

(繼承來源 ArrayList)
CopyTo(Array)

從目標陣列的開頭開始,將整個 ArrayList 複製至相容的一維 Array

(繼承來源 ArrayList)
CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 ArrayList 複製到相容的一維 Array

(繼承來源 ArrayList)
CopyTo(Int32, Array, Int32, Int32)

從目標陣列的指定索引開始,將項目範圍從 ArrayList 複製至相容的一維 Array

(繼承來源 ArrayList)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回整個 ArrayList 的列舉值。

(繼承來源 ArrayList)
GetEnumerator(Int32, Int32)

傳回適用於 ArrayList 中某段範圍項目的列舉程式。

(繼承來源 ArrayList)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetRange(Int32, Int32)

傳回 ArrayList,代表來源 ArrayList 中項目的子集。

(繼承來源 ArrayList)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(Object)

搜尋指定的 Object,並傳回在整個 ArrayList 中第一個符合項目之以零為起始的索引。

(繼承來源 ArrayList)
IndexOf(Object, Int32)

ArrayList 中從指定的索引開始到最後一個項目這段範圍內,搜尋指定的 Object 第一次出現的位置,並傳回其索引值 (索引以零起始)。

(繼承來源 ArrayList)
IndexOf(Object, Int32, Int32)

ArrayList 中從指定索引開始且包含指定項目個數的範圍內,搜尋指定的 Object 並傳回第一次出現的以零為起始的索引。

(繼承來源 ArrayList)
Insert(Int32, Object)

將指定的物件插入集合的指定位置。

InsertRange(Int32, ICollection)

將集合的項目插入位於指定索引的 ArrayList 中。

(繼承來源 ArrayList)
LastIndexOf(Object)

搜尋指定的 Object,並傳回在整個 ArrayList 中最後一個符合項目之以零為起始的索引。

(繼承來源 ArrayList)
LastIndexOf(Object, Int32)

ArrayList 中從第一個項目開始到指定的索引這個範圍內,搜尋指定的 Object,並傳回最後一次出現的索引值 (以零為起始)。

(繼承來源 ArrayList)
LastIndexOf(Object, Int32, Int32)

搜尋指定的 Object,並傳回 ArrayList 中包含指定之項目數且結束於指定之索引的項目範圍內,最後一個相符項目之以零為起始的索引。

(繼承來源 ArrayList)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(Object)

從集合中移除指定的項目。

RemoveAt(Int32)

從集合中指定的位置移除項目。

RemoveRange(Int32, Int32)

ArrayList 移除的項目範圍。

(繼承來源 ArrayList)
Reverse()

反轉整個 ArrayList 中項目的順序。

(繼承來源 ArrayList)
Reverse(Int32, Int32)

反向指定範圍中項目的順序。

(繼承來源 ArrayList)
SetRange(Int32, ICollection)

ArrayList 中項目的範圍內複製集合的項目。

(繼承來源 ArrayList)
Sort()

排序整個 ArrayList 中的項目。

(繼承來源 ArrayList)
Sort(IComparer)

使用指定的比較子來排序在整個 ArrayList 中的項目。

(繼承來源 ArrayList)
Sort(Int32, Int32, IComparer)

使用指定的比較子對 ArrayList 中某段範圍內的項目進行排序。

(繼承來源 ArrayList)
ToArray()

ArrayList 的項目複製到新的 Object 陣列。

(繼承來源 ArrayList)
ToArray(Type)

ArrayList 的項目複製到指定項目類型的新陣列。

(繼承來源 ArrayList)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TrimToSize()

將容量設為 ArrayList 中的實際項目數目。

(繼承來源 ArrayList)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱