BindingList<T> 類別

定義

提供支援資料繫結的泛型集合。Provides a generic collection that supports data binding.

generic <typename T>
public ref class BindingList : System::Collections::ObjectModel::Collection<T>, System::ComponentModel::IBindingList, System::ComponentModel::ICancelAddNew, System::ComponentModel::IRaiseItemChangedEvents
[System.Serializable]
public class BindingList<T> : System.Collections.ObjectModel.Collection<T>, System.ComponentModel.IBindingList, System.ComponentModel.ICancelAddNew, System.ComponentModel.IRaiseItemChangedEvents
type BindingList<'T> = class
    inherit Collection<'T>
    interface IBindingList
    interface ICancelAddNew
    interface IRaiseItemChangedEvents
    interface IList
    interface ICollection
    interface IEnumerable
Public Class BindingList(Of T)
Inherits Collection(Of T)
Implements IBindingList, ICancelAddNew, IRaiseItemChangedEvents

類型參數

T

清單中項目的類型。The type of elements in the list.

繼承
BindingList<T>
屬性
實作

範例

下列程式碼範例將示範如何系BindingList<T>結至包含商務物件的元件。The following code example demonstrates binding to a BindingList<T> component containing a business object. 這是包含Main方法的完整範例。This is a complete example that contains a Main method.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BindingListOfTExamples
{
    public partial class Form1 : Form
    {
        private TextBox textBox2;
        private ListBox listBox1;
        private Button button1;
        private TextBox textBox1;
        Random randomNumber = new Random();
    
        public Form1()
        {
           this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
           this.textBox1 = new System.Windows.Forms.TextBox();
           this.textBox2 = new System.Windows.Forms.TextBox();
           this.listBox1 = new System.Windows.Forms.ListBox();
           this.button1 = new System.Windows.Forms.Button();
           this.textBox1.Location = new System.Drawing.Point(169, 26);
           this.textBox1.Size = new System.Drawing.Size(100, 20);
           this.textBox1.Text = "Bracket";
           this.textBox2.Location = new System.Drawing.Point(169, 57);
           this.textBox2.ReadOnly = true;
           this.textBox2.Size = new System.Drawing.Size(100, 20);
           this.textBox2.Text = "4343";
           this.listBox1.FormattingEnabled = true;
           this.listBox1.Location = new System.Drawing.Point(12, 12);
           this.listBox1.Size = new System.Drawing.Size(120, 95);
           this.button1.Location = new System.Drawing.Point(180, 83);
           this.button1.Size = new System.Drawing.Size(75, 23);
           this.button1.Text = "Add New Item";
           this.button1.Click += new System.EventHandler(this.button1_Click);
           this.ClientSize = new System.Drawing.Size(292, 266);
           this.Controls.Add(this.button1);
           this.Controls.Add(this.listBox1);
           this.Controls.Add(this.textBox2);
           this.Controls.Add(this.textBox1);
           this.Text = "Parts Form";
           this.Load += new EventHandler(Form1_Load);
          
        }
    
        void Form1_Load(object sender, EventArgs e)
        {
            InitializeListOfParts();
            listBox1.DataSource = listOfParts;
            listBox1.DisplayMember = "PartName";
            listOfParts.AddingNew += new AddingNewEventHandler(listOfParts_AddingNew);
            listOfParts.ListChanged += new ListChangedEventHandler(listOfParts_ListChanged);
            
        }

       

        // Declare a new BindingListOfT with the Part business object.
        BindingList<Part> listOfParts; 
        private void InitializeListOfParts()
        {
            // Create the new BindingList of Part type.
            listOfParts = new BindingList<Part>();
    
            // Allow new parts to be added, but not removed once committed.        
            listOfParts.AllowNew = true;
            listOfParts.AllowRemove = false;

            // Raise ListChanged events when new parts are added.
            listOfParts.RaiseListChangedEvents = true;

            // Do not allow parts to be edited.
            listOfParts.AllowEdit = false;
            
            // Add a couple of parts to the list.
            listOfParts.Add(new Part("Widget", 1234));
            listOfParts.Add(new Part("Gadget", 5647));
        }

        
        // Create a new part from the text in the two text boxes.
        void listOfParts_AddingNew(object sender, AddingNewEventArgs e)
        {
            e.NewObject = new Part(textBox1.Text, int.Parse(textBox2.Text));
            
        }

        
        // Add the new part unless the part number contains
        // spaces. In that case cancel the add.
        private void button1_Click(object sender, EventArgs e)
        {
            Part newPart = listOfParts.AddNew();

            if (newPart.PartName.Contains(" "))
            {
                MessageBox.Show("Part names cannot contain spaces.");
                listOfParts.CancelNew(listOfParts.IndexOf(newPart));
            }
            else
            {
                textBox2.Text = randomNumber.Next(9999).ToString();
                textBox1.Text = "Enter part name";
            }
        }

        void listOfParts_ListChanged(object sender, ListChangedEventArgs e)
        {
            MessageBox.Show(e.ListChangedType.ToString());
        }

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

    }
    
    // A simple business object for example purposes.
    public class Part
    {
        private string name;
        private int number;
        public Part() { }
        public Part(string nameForPart, int numberForPart)
        {
            PartName = nameForPart;
            PartNumber = numberForPart;
        }

        public string PartName
        {
            get { return name; }
            set { name = value; }
        }

        public int PartNumber
        {
            get { return number; }
            set { number = value; }
        }
    }
}

Option Explicit On
Option Strict On
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Class Form1
    Inherits Form

    Private textBox2 As TextBox
    Private listBox1 As ListBox
    Private WithEvents button1 As Button
    Private textBox1 As TextBox
    Private randomNumber As New Random()

    Public Sub New()
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.textBox1 = New System.Windows.Forms.TextBox()
        Me.textBox2 = New System.Windows.Forms.TextBox()
        Me.listBox1 = New System.Windows.Forms.ListBox()
        Me.button1 = New System.Windows.Forms.Button()
        Me.textBox1.Location = New System.Drawing.Point(169, 26)
        Me.textBox1.Size = New System.Drawing.Size(100, 20)
        Me.textBox1.Text = "Bracket"
        Me.textBox2.Location = New System.Drawing.Point(169, 57)
        Me.textBox2.ReadOnly = True
        Me.textBox2.Size = New System.Drawing.Size(100, 20)
        Me.textBox2.Text = "4343"
        Me.listBox1.FormattingEnabled = True
        Me.listBox1.Location = New System.Drawing.Point(12, 12)
        Me.listBox1.Size = New System.Drawing.Size(120, 95)
        Me.button1.Location = New System.Drawing.Point(180, 83)
        Me.button1.Size = New System.Drawing.Size(75, 23)
        Me.button1.Text = "Add New Item"
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.button1)
        Me.Controls.Add(Me.listBox1)
        Me.Controls.Add(Me.textBox2)
        Me.Controls.Add(Me.textBox1)
        Me.Text = "Parts Form"
        AddHandler Me.Load, AddressOf Form1_Load

    End Sub

    Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        InitializeListOfParts()
        listBox1.DataSource = listOfParts
        listBox1.DisplayMember = "PartName"
    End Sub

    ' Declare a new BindingListOfT with the Part business object.
    Private WithEvents listOfParts As BindingList(Of Part)

    Private Sub InitializeListOfParts()

        ' Create the new BindingList of Part type.
        listOfParts = New BindingList(Of Part)

        ' Allow new parts to be added, but not removed once committed.        
        listOfParts.AllowNew = True
        listOfParts.AllowRemove = False

        ' Raise ListChanged events when new parts are added.
        listOfParts.RaiseListChangedEvents = True

        ' Do not allow parts to be edited.
        listOfParts.AllowEdit = False

        ' Add a couple of parts to the list.
        listOfParts.Add(New Part("Widget", 1234))
        listOfParts.Add(New Part("Gadget", 5647))

    End Sub

    ' Create a new part from the text in the two text boxes.
    Private Sub listOfParts_AddingNew(ByVal sender As Object, _
        ByVal e As AddingNewEventArgs) Handles listOfParts.AddingNew
        e.NewObject = New Part(textBox1.Text, Integer.Parse(textBox2.Text))

    End Sub


    ' Add the new part unless the part number contains
    ' spaces. In that case cancel the add.
    Private Sub button1_Click(ByVal sender As Object, _
        ByVal e As EventArgs) Handles button1.Click

        Dim newPart As Part = listOfParts.AddNew()

        If newPart.PartName.Contains(" ") Then
            MessageBox.Show("Part names cannot contain spaces.")
            listOfParts.CancelNew(listOfParts.IndexOf(newPart))
        Else
            textBox2.Text = randomNumber.Next(9999).ToString()
            textBox1.Text = "Enter part name"
        End If

    End Sub

    <STAThread()> _
    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New Form1())

    End Sub
End Class

' A simple business object for example purposes.
Public Class Part
    Private name As String
    Private number As Integer

    Public Sub New()
    End Sub

    Public Sub New(ByVal nameForPart As String, _
        ByVal numberForPart As Integer)
        PartName = nameForPart
        PartNumber = numberForPart

    End Sub


    Public Property PartName() As String
        Get
            Return name
        End Get
        Set(ByVal value As String)
            name = Value
        End Set
    End Property

    Public Property PartNumber() As Integer
        Get
            Return number
        End Get
        Set(ByVal value As Integer)
            number = Value
        End Set
    End Property
End Class

備註

BindingList<T>類別可以用來做為基類, 以建立雙向資料系結機制。The BindingList<T> class can be used as a base class to create a two-way data-binding mechanism. BindingList<T>提供IBindingList介面的具體泛型實作為。BindingList<T> provides a concrete, generic implementation of the IBindingList interface. 這是IBindingList執行完整介面的替代方法, 這可能會很棘手, 因為、 IEditableObject和相關聯IBindingList CurrencyManager的之間有細微的互動。This is an alternative to implementing the complete IBindingList interface, which can be difficult because of the subtle interaction between IBindingList, IEditableObject, and the associated CurrencyManager. 不過, 一般解決方案程式設計人員將會使用提供資料系結功能的類別, BindingSource例如, 而不是BindingList<T>直接使用。However, the typical solutions programmer will use a class that provides data binding functionality, such as BindingSource, instead of directly using BindingList<T>.

BindingList<T>透過可延伸的AddNew方法支援 factory 建立的實例。BindingList<T> supports factory-created instances through the extensible AddNew method. (此外, 也可以在其他類別中找到這種類型的擴充BindingSource性, 例如), 因為這個類別ICancelAddNew會實作為介面, 所以它會透過EndNewCancelNew來啟用新專案的交易認可或回復方法。(This same type of extensibility is also found in other classes, such as BindingSource) In addition, since this class implements the ICancelAddNew interface, it enables transactional commits or rollbacks of the new item through the EndNew and CancelNew methods.

建構函式

BindingList<T>()

使用預設值,初始化 BindingList<T> 類別的新執行個體。Initializes a new instance of the BindingList<T> class using default values.

BindingList<T>(IList<T>)

使用指定的清單,初始化 BindingList<T> 類別的新執行個體。Initializes a new instance of the BindingList<T> class with the specified list.

屬性

AllowEdit

取得或設定值,指出清單中的項目是否可以編輯。Gets or sets a value indicating whether items in the list can be edited.

AllowNew

取得或設定值,指出您是否可以使用 AddNew() 方法,將項目加入至清單中。Gets or sets a value indicating whether you can add items to the list using the AddNew() method.

AllowRemove

取得或設定值,指出您是否可以從集合移除項目。Gets or sets a value indicating whether you can remove items from the collection.

Count

取得 Collection<T> 中實際包含的項目數目。Gets the number of elements actually contained in the Collection<T>.

(繼承來源 Collection<T>)
IsSortedCore

取得值,指出清單是否為排序。Gets a value indicating whether the list is sorted.

Item[Int32]

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

(繼承來源 Collection<T>)
Items

取得 IList<T> 周圍的 Collection<T> 包裝函式。Gets a IList<T> wrapper around the Collection<T>.

(繼承來源 Collection<T>)
RaiseListChangedEvents

取得或設定值,指出在清單中加入或移除項目時是否引發 ListChanged 事件。Gets or sets a value indicating whether adding or removing items within the list raises ListChanged events.

SortDirectionCore

取得清單的排序方向。Gets the direction the list is sorted.

SortPropertyCore

如果在衍生類別中實作排序,取得排序清單時所使用的屬性描述項,否則傳回 nullGets the property descriptor that is used for sorting the list if sorting is implemented in a derived class; otherwise, returns null.

SupportsChangeNotificationCore

取得值,指出是否已啟用 ListChanged 事件。Gets a value indicating whether ListChanged events are enabled.

SupportsSearchingCore

取得值,指出清單是否支援搜尋。Gets a value indicating whether the list supports searching.

SupportsSortingCore

取得值,指出清單是否支援排序。Gets a value indicating whether the list supports sorting.

方法

Add(T)

將物件加入至 Collection<T> 的末端。Adds an object to the end of the Collection<T>.

(繼承來源 Collection<T>)
AddNew()

將新項目加入至集合中。Adds a new item to the collection.

AddNewCore()

將新項目加入至集合的結尾。Adds a new item to the end of the collection.

ApplySortCore(PropertyDescriptor, ListSortDirection)

如果在衍生類別中覆寫時,排序項目,否則擲回 NotSupportedExceptionSorts the items if overridden in a derived class; otherwise, throws a NotSupportedException.

CancelNew(Int32)

捨棄暫止的新項目。Discards a pending new item.

Clear()

移除 Collection<T> 中的所有項目。Removes all elements from the Collection<T>.

(繼承來源 Collection<T>)
ClearItems()

從集合中移除所有項目。Removes all elements from the collection.

Contains(T)

判斷某項目是否在 Collection<T> 中。Determines whether an element is in the Collection<T>.

(繼承來源 Collection<T>)
CopyTo(T[], Int32)

從目標陣列的指定索引開始,將整個 Collection<T> 複製到相容的一維 ArrayCopies the entire Collection<T> to a compatible one-dimensional Array, starting at the specified index of the target array.

(繼承來源 Collection<T>)
EndNew(Int32)

將暫止的新項目認可到集合中。Commits a pending new item to the collection.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
FindCore(PropertyDescriptor, Object)

如果在衍生類別中實作搜尋時,搜尋具有指定之屬性描述項和值之項目的索引,否則為 NotSupportedExceptionSearches for the index of the item that has the specified property descriptor with the specified value, if searching is implemented in a derived class; otherwise, a NotSupportedException.

GetEnumerator()

傳回在 Collection<T> 中逐一查看的列舉值。Returns an enumerator that iterates through the Collection<T>.

(繼承來源 Collection<T>)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(T)

搜尋指定的物件,並傳回整個 Collection<T> 中第一個相符項目之以零起始的索引。Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection<T>.

(繼承來源 Collection<T>)
Insert(Int32, T)

將項目插入至 Collection<T> 中指定的索引位置。Inserts an element into the Collection<T> at the specified index.

(繼承來源 Collection<T>)
InsertItem(Int32, T)

將指定的項目插入清單中的指定索引處。Inserts the specified item in the list at the specified index.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnAddingNew(AddingNewEventArgs)

引發 AddingNew 事件。Raises the AddingNew event.

OnListChanged(ListChangedEventArgs)

引發 ListChanged 事件。Raises the ListChanged event.

Remove(T)

Collection<T> 移除特定物件之第一個符合的元素。Removes the first occurrence of a specific object from the Collection<T>.

(繼承來源 Collection<T>)
RemoveAt(Int32)

移除 Collection<T> 之指定索引處的項目。Removes the element at the specified index of the Collection<T>.

(繼承來源 Collection<T>)
RemoveItem(Int32)

移除在指定索引處的項目。Removes the item at the specified index.

RemoveSortCore()

如果在衍生類別中實作排序時,移除以 ApplySortCore(PropertyDescriptor, ListSortDirection) 所套用的任何排序,否則引發 NotSupportedExceptionRemoves any sort applied with ApplySortCore(PropertyDescriptor, ListSortDirection) if sorting is implemented in a derived class; otherwise, raises NotSupportedException.

ResetBindings()

引發 ListChanged 型別的 Reset 事件。Raises a ListChanged event of type Reset.

ResetItem(Int32)

為指定之位置的項目,引發 ListChanged 型別的 ItemChanged 事件。Raises a ListChanged event of type ItemChanged for the item at the specified position.

SetItem(Int32, T)

以指定的項目取代位於指定索引上的項目。Replaces the item at the specified index with the specified item.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

AddingNew

在項目加入至清單之前發生。Occurs before an item is added to the list.

ListChanged

在清單變更或清單項目變更時發生。Occurs when the list or an item in the list changes.

明確介面實作

IBindingList.AddIndex(PropertyDescriptor)

如需這個成員的說明,請參閱 AddIndex(PropertyDescriptor)For a description of this member, see AddIndex(PropertyDescriptor).

IBindingList.AddNew()

將新的項目加入至清單中。Adds a new item to the list. 如需詳細資訊,請參閱AddNew()For more information, see AddNew().

IBindingList.AllowEdit

取得值,指出清單中的項目是否可以編輯。Gets a value indicating whether items in the list can be edited.

IBindingList.AllowNew

取得值,指出是否可以使用 AddNew() 方法,將新項目加入至清單中。Gets a value indicating whether new items can be added to the list using the AddNew() method.

IBindingList.AllowRemove

取得值,指出是否可以從清單中移除項目。Gets a value indicating whether items can be removed from the list.

IBindingList.ApplySort(PropertyDescriptor, ListSortDirection)

根據 PropertyDescriptorListSortDirection 來排序清單。Sorts the list based on a PropertyDescriptor and a ListSortDirection. 如需這個成員的完整說明,請參閱 ApplySort(PropertyDescriptor, ListSortDirection)For a complete description of this member, see ApplySort(PropertyDescriptor, ListSortDirection).

IBindingList.Find(PropertyDescriptor, Object)

如需這個成員的說明,請參閱 Find(PropertyDescriptor, Object)For a description of this member, see Find(PropertyDescriptor, Object).

IBindingList.IsSorted

如需這個成員的說明,請參閱 IsSortedFor a description of this member, see IsSorted.

IBindingList.RemoveIndex(PropertyDescriptor)

如需這個成員的說明,請參閱 RemoveIndex(PropertyDescriptor)For a description of this member, see RemoveIndex(PropertyDescriptor).

IBindingList.RemoveSort()

如需這個成員的描述,請參閱 RemoveSort()For a description of this member, see RemoveSort()

IBindingList.SortDirection

如需這個成員的說明,請參閱 SortDirectionFor a description of this member, see SortDirection.

IBindingList.SortProperty

如需這個成員的說明,請參閱 SortPropertyFor a description of this member, see SortProperty.

IBindingList.SupportsChangeNotification

如需這個成員的說明,請參閱 SupportsChangeNotificationFor a description of this member, see SupportsChangeNotification.

IBindingList.SupportsSearching

如需這個成員的說明,請參閱 SupportsSearchingFor a description of this member, see SupportsSearching.

IBindingList.SupportsSorting

如需這個成員的說明,請參閱 SupportsSortingFor a description of this member, see SupportsSorting.

ICollection.CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection to an Array, starting at a particular Array index.

(繼承來源 Collection<T>)
ICollection.IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

(繼承來源 Collection<T>)
ICollection.SyncRoot

取得可用以同步存取 ICollection 的物件。Gets an object that can be used to synchronize access to the ICollection.

(繼承來源 Collection<T>)
ICollection<T>.IsReadOnly

取得值,指出 ICollection<T> 是否唯讀。Gets a value indicating whether the ICollection<T> is read-only.

(繼承來源 Collection<T>)
IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection.

(繼承來源 Collection<T>)
IList.Add(Object)

將項目加入至 IListAdds an item to the IList.

(繼承來源 Collection<T>)
IList.Contains(Object)

判斷 IList 是否包含特定值。Determines whether the IList contains a specific value.

(繼承來源 Collection<T>)
IList.IndexOf(Object)

判斷 IList 中指定項目的索引。Determines the index of a specific item in the IList.

(繼承來源 Collection<T>)
IList.Insert(Int32, Object)

將項目插入 IList 中指定的索引處。Inserts an item into the IList at the specified index.

(繼承來源 Collection<T>)
IList.IsFixedSize

取得值,指出 IList 是否有固定的大小。Gets a value indicating whether the IList has a fixed size.

(繼承來源 Collection<T>)
IList.IsReadOnly

取得值,指出 IList 是否唯讀。Gets a value indicating whether the IList is read-only.

(繼承來源 Collection<T>)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

(繼承來源 Collection<T>)
IList.Remove(Object)

IList 移除特定物件之第一個符合的元素。Removes the first occurrence of a specific object from the IList.

(繼承來源 Collection<T>)
IRaiseItemChangedEvents.RaisesItemChangedEvents

取得值,指出項目屬性值變更是否會引發 ListChanged 型別的 ItemChanged 事件。Gets a value indicating whether item property value changes raise ListChanged events of type ItemChanged. 在衍生類別中不可覆寫這個成員。This member cannot be overridden in a derived class.

擴充方法

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於

另請參閱