BindingSource BindingSource BindingSource BindingSource Class

定义

封装窗体的数据源。Encapsulates the data source for a form.

public ref class BindingSource : System::ComponentModel::Component, System::Collections::IList, System::ComponentModel::IBindingListView, System::ComponentModel::ICancelAddNew, System::ComponentModel::ISupportInitializeNotification, System::ComponentModel::ITypedList, System::Windows::Forms::ICurrencyManagerProvider
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
public class BindingSource : System.ComponentModel.Component, System.Collections.IList, System.ComponentModel.IBindingListView, System.ComponentModel.ICancelAddNew, System.ComponentModel.ISupportInitializeNotification, System.ComponentModel.ITypedList, System.Windows.Forms.ICurrencyManagerProvider
type BindingSource = class
    inherit Component
    interface IBindingListView
    interface IBindingList
    interface IList
    interface ICollection
    interface IEnumerable
    interface ITypedList
    interface ICancelAddNew
    interface ISupportInitializeNotification
    interface ISupportInitialize
    interface ICurrencyManagerProvider
Public Class BindingSource
Inherits Component
Implements IBindingListView, ICancelAddNew, ICurrencyManagerProvider, IList, ISupportInitializeNotification, ITypedList
继承
属性
实现

示例

下面的代码示例演示ListBox绑定到BindingSourceThe following code example demonstrates a ListBox bound to a BindingSource. BindingSource绑定到BindingList<T>包含字体的列表。The BindingSource is bound to a BindingList<T> that contains a list of fonts.

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

namespace BindingSourceExamples
{
    public class Form1 : Form
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.Load += new EventHandler(Form1_Load);
        }

        private TextBox textBox1;
        private Button button1;
        private ListBox listBox1;
       
        private BindingSource binding1;
        void Form1_Load(object sender, EventArgs e)
        {
            listBox1 = new ListBox();
            textBox1 = new TextBox();
            binding1 = new BindingSource();
            button1 = new Button();
            listBox1.Location = new Point(140, 25);
            listBox1.Size = new Size(123, 160);
            textBox1.Location = new Point(23, 70);
            textBox1.Size = new Size(100, 20);
            textBox1.Text = "Wingdings";
            button1.Location = new Point(23, 25);
            button1.Size = new Size(75, 23);
            button1.Text = "Search";
            button1.Click += new EventHandler(this.button1_Click);
            this.ClientSize = new Size(292, 266);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.listBox1);

            MyFontList fonts = new MyFontList();
            for (int i = 0; i < FontFamily.Families.Length; i++)
            {
                if (FontFamily.Families[i].IsStyleAvailable(FontStyle.Regular))
                    fonts.Add(new Font(FontFamily.Families[i], 11.0F, FontStyle.Regular));
            }
            binding1.DataSource = fonts;
            listBox1.DataSource = binding1;
            listBox1.DisplayMember = "Name";

        }

  
        private void button1_Click(object sender, EventArgs e)
        {
            if (binding1.SupportsSearching != true)
                MessageBox.Show("Cannot search the list.");
            else
            {
                int foundIndex = binding1.Find("Name", textBox1.Text);
                if (foundIndex > -1)
                    listBox1.SelectedIndex = foundIndex;
                else
                    MessageBox.Show("Font was not found.");
            }
        }
    }
    
    public class MyFontList : BindingList<Font>
    {

        protected override bool SupportsSearchingCore
        {
            get { return true; }
        }
        protected override int FindCore(PropertyDescriptor prop, object key)
        {
            // Ignore the prop value and search by family name.
            for (int i = 0; i < Count; ++i)
            {
                if (Items[i].FontFamily.Name.ToLower() == ((string)key).ToLower())
                    return i;

            }
            return -1;
        }


    }
  
}
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Public Class Form1
    Inherits Form

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

    End Sub

    Public Sub New()

    End Sub

    Private textBox1 As TextBox
    Private WithEvents button1 As Button
    Private listBox1 As ListBox
    Private components As IContainer
    Private binding1 As BindingSource

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        listBox1 = New ListBox()
        textBox1 = New TextBox()
        binding1 = New BindingSource()
        button1 = New Button()
        listBox1.Location = New Point(140, 25)
        listBox1.Size = New Size(123, 160)
        textBox1.Location = New Point(23, 70)
        textBox1.Size = New Size(100, 20)
        textBox1.Text = "Wingdings"
        button1.Location = New Point(23, 25)
        button1.Size = New Size(75, 23)
        button1.Text = "Search"
        Me.ClientSize = New Size(292, 266)
        Me.Controls.Add(Me.button1)
        Me.Controls.Add(Me.textBox1)
        Me.Controls.Add(Me.listBox1)

        Dim fonts As New MyFontList()
        Dim i As Integer
        For i = 0 To FontFamily.Families.Length - 1
            If FontFamily.Families(i).IsStyleAvailable(FontStyle.Regular) Then
                fonts.Add(New Font(FontFamily.Families(i), 11.0F, FontStyle.Regular))
            End If
        Next i
        binding1.DataSource = fonts
        listBox1.DataSource = binding1
        listBox1.DisplayMember = "Name"

    End Sub
    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
        Handles button1.Click

        If binding1.SupportsSearching <> True Then
            MessageBox.Show("Cannot search the list.")
        Else
            Dim foundIndex As Integer = binding1.Find("Name", textBox1.Text)
            If foundIndex > -1 Then
                listBox1.SelectedIndex = foundIndex
            Else
                MessageBox.Show("Font was not found.")
            End If
        End If

    End Sub
End Class

Public Class MyFontList
    Inherits BindingList(Of Font)

    Protected Overrides ReadOnly Property SupportsSearchingCore() As Boolean
        Get
            Return True
        End Get
    End Property
    
    Protected Overrides Function FindCore(ByVal prop As PropertyDescriptor, _
        ByVal key As Object) As Integer
        ' Ignore the prop value and search by family name.
        Dim i As Integer
        While i < Count
            If Items(i).FontFamily.Name.ToLower() = CStr(key).ToLower() Then
                Return i
            End If
            i += 1
        End While

        Return -1
    End Function
End Class

注解

BindingSource组件有许多用途。The BindingSource component serves many purposes. 首先,它通过提供货币管理、 更改通知和 Windows 窗体控件与数据源之间的其他服务简化将控件绑定到数据窗体上。First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. 这可以通过附加BindingSource组件为数据源使用DataSource属性。This is accomplished by attaching the BindingSource component to your data source using the DataSource property. 对于复杂绑定方案,您可以选择设置DataMember到特定列或列表数据源中的属性。For complex binding scenarios you can optionally set the DataMember property to a specific column or list in the data source. 您然后将控件绑定到BindingSourceYou then bind controls to the BindingSource. 数据的所有进一步交互都通过调用到BindingSource组件。All further interaction with the data is accomplished with calls to the BindingSource component. 有关如何在示例BindingSource可简化绑定过程,请参阅如何:将 Windows 窗体控件绑定到 DBNull 数据库值如何:处理错误和因数据绑定而发生的异常For examples on how the BindingSource can simplify the binding process, see How to: Bind Windows Forms Controls to DBNull Database Values and How to: Handle Errors and Exceptions that Occur with Databinding. 导航和更新的数据源通过实现方法如MoveNextMoveLast,和RemoveNavigation and updating of the data source is accomplished through methods such as MoveNext, MoveLast, and Remove. 通过处理排序和筛选等操作SortFilter属性。Operations such as sorting and filtering are handled through the Sort and Filter properties. 有关详细信息使用的排序和筛选与BindingSource,请参阅如何:排序和筛选 ADO.NET 数据使用 Windows 窗体 BindingSource 组件For more information on using sorting and filtering with the BindingSource, see How to: Sort and Filter ADO.NET Data with the Windows Forms BindingSource Component.

此外,BindingSource组件可以充当强类型化的数据源。In addition, the BindingSource component can act as a strongly typed data source. 通常在基础数据源的类型是通过以下机制之一已修复:Typically the type of the underlying data source is fixed through one of the following mechanisms:

这两种机制创建强类型列表。Both of these mechanisms create a strongly-typed list. 有关如何使用的详细信息BindingSource若要将绑定到一个类型,请参阅如何:将 Windows 窗体控件绑定到类型For more information on how to use the BindingSource to bind to a type, see How to: Bind a Windows Forms Control to a Type. 此外可以使用BindingSource将控件绑定到 factory 对象。You can also use the BindingSource to bind your controls to a factory object. 有关如何执行此操作的详细信息,请参阅如何:Windows 窗体控件绑定到 Factory 对象For more information on how to do this, see How to: Bind a Windows Forms Control to a Factory Object.

备注

因为BindingSource句柄这两个简单和复杂数据源,术语会产生问题。Because a BindingSource handles both simple and complex data sources, terminology is problematic. 在此类文档,术语列表指的是托管的数据源中的数据集合并表示单个元素。Within this class documentation, the term list refers to a data collection within the hosted data source, and item denotes a single element. 当讨论功能关联到复杂的数据源等效术语使用。When discussing functionality associated with complex data sources, the equivalent terms table and row are used.

BindingSource 提供用于访问基础数据成员。BindingSource provides members for accessing the underlying data. 可以通过检索当前项Current属性,然后将整个列表可以检索通过List属性。The current item can be retrieved through the Current property, and the entire list can be retrieved through the List property. 支持对当前项通过编辑操作CurrentRemoveCurrentEndEditCancelEditAddAddNew方法。Editing operations are supported on the current item through Current and the RemoveCurrent, EndEdit, CancelEdit and Add and AddNew methods. 尽管货币管理自动处理所有基础数据源类型,此类公开的大量事件,如CurrentItemChangedDataSourceChanged,允许自定义。Although currency management is handled automatically for all underlying data source types, this class exposes a number of events, such as CurrentItemChanged and DataSourceChanged, that allow for customization.

绑定到的数据源BindingSource组件也可以导航和管理与BindingNavigator类,该类用于导航列表中的项提供类似于 VCR 的用户界面 (UI)。Data sources that are bound to a BindingSource component can also be navigated and managed with the BindingNavigator class, which provides a VCR-like user interface (UI) for navigating items within a list. 尽管BindingNavigator可以绑定到任何数据源,它的设计与集成BindingSource组件通过其BindingNavigator.BindingSource属性。Although BindingNavigator can be bound to any data source, it was designed to integrate with a BindingSource component through its BindingNavigator.BindingSource property.

默认属性BindingSource类是DataSourceThe default property for the BindingSource class is DataSource. 默认事件是CurrentChangedThe default event is CurrentChanged.

注意

成员的许多BindingSource类对表示的基础列表List属性,并且只引用基础列表对其操作。Many of the members of the BindingSource class operate on the underlying list represented by the List property and simply refer their operation to the underlying list. 因此,当BindingSource绑定到的自定义实现IList,这些成员的具体行为可能不同于文档中所述的行为。Therefore, when the BindingSource is bound to a custom implementation of IList, the exact behavior of these members may differ from the behavior described in the class documentation. 例如,RemoveAt方法调用IList.RemoveAtFor example, the RemoveAt method calls IList.RemoveAt. BindingSource文档介绍RemoveAt方法,并介绍该RemoveAt基础方法IList正确实现。The BindingSource documentation describes the RemoveAt method with the understanding that the RemoveAt method for the underlying IList is correctly implemented.

构造函数

BindingSource() BindingSource() BindingSource() BindingSource()

初始化的新实例BindingSource类为默认属性值。Initializes a new instance of the BindingSource class to the default property values.

BindingSource(IContainer) BindingSource(IContainer) BindingSource(IContainer) BindingSource(IContainer)

初始化的新实例BindingSource类并添加BindingSource到指定的容器。Initializes a new instance of the BindingSource class and adds the BindingSource to the specified container.

BindingSource(Object, String) BindingSource(Object, String) BindingSource(Object, String) BindingSource(Object, String)

初始化的新实例BindingSource与指定的数据源和数据成员的类。Initializes a new instance of the BindingSource class with the specified data source and data member.

属性

AllowEdit AllowEdit AllowEdit AllowEdit

获取一个值,该值指示是否可以编辑基础列表中的项。Gets a value indicating whether items in the underlying list can be edited.

AllowNew AllowNew AllowNew AllowNew

获取或设置一个值,该值指示是否AddNew()方法可用于向列表添加项。Gets or sets a value indicating whether the AddNew() method can be used to add items to the list.

AllowRemove AllowRemove AllowRemove AllowRemove

获取一个值,它指示是否可从基础列表中移除项。Gets a value indicating whether items can be removed from the underlying list.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(Inherited from Component)
Count Count Count Count

获取在基础列表中,考虑当前的总项数Filter纳入考虑范围的值。Gets the total number of items in the underlying list, taking the current Filter value into consideration.

CurrencyManager CurrencyManager CurrencyManager CurrencyManager

获取与此关联的货币管理器BindingSourceGets the currency manager associated with this BindingSource.

Current Current Current Current

获取列表中的当前项。Gets the current item in the list.

DataMember DataMember DataMember DataMember

获取或设置连接器当前绑定到的数据源中的特定列表。Gets or sets the specific list in the data source to which the connector currently binds to.

DataSource DataSource DataSource DataSource

获取或设置连接器绑定到的数据源。Gets or sets the data source that the connector binds to.

DesignMode DesignMode DesignMode DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Filter Filter Filter Filter

获取或设置用于筛选查看哪些行的表达式。Gets or sets the expression used to filter which rows are viewed.

IsBindingSuspended IsBindingSuspended IsBindingSuspended IsBindingSuspended

获取一个值,该值指示列表绑定是否已挂起。Gets a value indicating whether the list binding is suspended.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

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

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示基础列表是否为只读。Gets a value indicating whether the underlying list is read-only.

IsSorted IsSorted IsSorted IsSorted

获取一个值,该值指示是否在基础列表中的项进行排序。Gets a value indicating whether the items in the underlying list are sorted.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取或设置指定索引处的列表元素。Gets or sets the list element at the specified index.

List List List List

获取连接器绑定到的列表。Gets the list that the connector is bound to.

Position Position Position Position

获取或设置基础列表中当前项的索引。Gets or sets the index of the current item in the underlying list.

RaiseListChangedEvents RaiseListChangedEvents RaiseListChangedEvents RaiseListChangedEvents

获取或设置一个值,该值指示是否ListChanged应引发事件。Gets or sets a value indicating whether ListChanged events should be raised.

Site Site Site Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
Sort Sort Sort Sort

获取或设置用于排序的列名称以及用于查看数据源中的行的排序顺序。Gets or sets the column names used for sorting, and the sort order for viewing the rows in the data source.

SortDescriptions SortDescriptions SortDescriptions SortDescriptions

获取应用于数据源的排序说明的集合。Gets the collection of sort descriptions applied to the data source.

SortDirection SortDirection SortDirection SortDirection

获取列表中项的排序方向。Gets the direction the items in the list are sorted.

SortProperty SortProperty SortProperty SortProperty

获取PropertyDescriptor正在用于排序列表。Gets the PropertyDescriptor that is being used for sorting the list.

SupportsAdvancedSorting SupportsAdvancedSorting SupportsAdvancedSorting SupportsAdvancedSorting

获取一个值,它指示数据源是否支持多列排序。Gets a value indicating whether the data source supports multi-column sorting.

SupportsChangeNotification SupportsChangeNotification SupportsChangeNotification SupportsChangeNotification

获取一个值,它指示数据源是否支持更改通知。Gets a value indicating whether the data source supports change notification.

SupportsFiltering SupportsFiltering SupportsFiltering SupportsFiltering

获取一个值,该值指示数据源是否支持筛选。Gets a value indicating whether the data source supports filtering.

SupportsSearching SupportsSearching SupportsSearching SupportsSearching

获取一个值,该值指示数据源是否支持使用搜索Find(PropertyDescriptor, Object)方法。Gets a value indicating whether the data source supports searching with the Find(PropertyDescriptor, Object) method.

SupportsSorting SupportsSorting SupportsSorting SupportsSorting

获取一个值,它指示数据源是否支持排序。Gets a value indicating whether the data source supports sorting.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步对基础列表的访问的对象。Gets an object that can be used to synchronize access to the underlying list.

方法

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

将现有项添加到内部列表中。Adds an existing item to the internal list.

AddNew() AddNew() AddNew() AddNew()

在基础列表中添加一个新项。Adds a new item to the underlying list.

ApplySort(ListSortDescriptionCollection) ApplySort(ListSortDescriptionCollection) ApplySort(ListSortDescriptionCollection) ApplySort(ListSortDescriptionCollection)

使用指定的排序说明对数据源进行排序。Sorts the data source with the specified sort descriptions.

ApplySort(PropertyDescriptor, ListSortDirection) ApplySort(PropertyDescriptor, ListSortDirection) ApplySort(PropertyDescriptor, ListSortDirection) ApplySort(PropertyDescriptor, ListSortDirection)

使用指定的属性说明符和排序方向对数据源进行排序。Sorts the data source using the specified property descriptor and sort direction.

CancelEdit() CancelEdit() CancelEdit() CancelEdit()

取消当前的编辑操作。Cancels the current edit operation.

Clear() Clear() Clear() Clear()

从列表中移除所有元素。Removes all elements from the list.

Contains(Object) Contains(Object) Contains(Object) Contains(Object)

确定某个对象是否为列表中的项。Determines whether an object is an item in the list.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

内容复制List到指定的数组,从指定的索引值处开始。Copies the contents of the List to the specified array, starting at the specified index value.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 BindingSource 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the BindingSource and optionally releases the managed resources.

EndEdit() EndEdit() EndEdit() EndEdit()

将挂起的更改应用于基础数据源。Applies pending changes to the underlying data source.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
Find(PropertyDescriptor, Object) Find(PropertyDescriptor, Object) Find(PropertyDescriptor, Object) Find(PropertyDescriptor, Object)

搜索具有指定属性描述符的项索引。Searches for the index of the item that has the given property descriptor.

Find(String, Object) Find(String, Object) Find(String, Object) Find(String, Object)

使用指定的属性名和值返回列表中的项的索引。Returns the index of the item in the list with the specified property name and value.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

检索的枚举器ListRetrieves an enumerator for the List.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetItemProperties(PropertyDescriptor[]) GetItemProperties(PropertyDescriptor[]) GetItemProperties(PropertyDescriptor[]) GetItemProperties(PropertyDescriptor[])

检索的数组PropertyDescriptor对象表示可绑定属性的数据源列表类型。Retrieves an array of PropertyDescriptor objects representing the bindable properties of the data source list type.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetListName(PropertyDescriptor[]) GetListName(PropertyDescriptor[]) GetListName(PropertyDescriptor[]) GetListName(PropertyDescriptor[])

获取为绑定提供数据的列表的名称。Gets the name of the list supplying data for the binding.

GetRelatedCurrencyManager(String) GetRelatedCurrencyManager(String) GetRelatedCurrencyManager(String) GetRelatedCurrencyManager(String)

为指定的数据成员获取相关的当前项管理器。Gets the related currency manager for the specified data member.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

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

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

搜索指定的对象,并返回整个列表中第一个匹配项的索引。Searches for the specified object and returns the index of the first occurrence within the entire list.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object)

将一项插入列表中指定的索引处。Inserts an item into the list at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
MoveFirst() MoveFirst() MoveFirst() MoveFirst()

移至列表中的第一项。Moves to the first item in the list.

MoveLast() MoveLast() MoveLast() MoveLast()

移至列表中的最后一项。Moves to the last item in the list.

MoveNext() MoveNext() MoveNext() MoveNext()

移至列表中的下一项。Moves to the next item in the list.

MovePrevious() MovePrevious() MovePrevious() MovePrevious()

移至列表中的上一项。Moves to the previous item in the list.

OnAddingNew(AddingNewEventArgs) OnAddingNew(AddingNewEventArgs) OnAddingNew(AddingNewEventArgs) OnAddingNew(AddingNewEventArgs)

引发 AddingNew 事件。Raises the AddingNew event.

OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs)

引发 BindingComplete 事件。Raises the BindingComplete event.

OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs)

引发 CurrentChanged 事件。Raises the CurrentChanged event.

OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs)

引发 CurrentItemChanged 事件。Raises the CurrentItemChanged event.

OnDataError(BindingManagerDataErrorEventArgs) OnDataError(BindingManagerDataErrorEventArgs) OnDataError(BindingManagerDataErrorEventArgs) OnDataError(BindingManagerDataErrorEventArgs)

引发 DataError 事件。Raises the DataError event.

OnDataMemberChanged(EventArgs) OnDataMemberChanged(EventArgs) OnDataMemberChanged(EventArgs) OnDataMemberChanged(EventArgs)

引发 DataMemberChanged 事件。Raises the DataMemberChanged event.

OnDataSourceChanged(EventArgs) OnDataSourceChanged(EventArgs) OnDataSourceChanged(EventArgs) OnDataSourceChanged(EventArgs)

引发 DataSourceChanged 事件。Raises the DataSourceChanged event.

OnListChanged(ListChangedEventArgs) OnListChanged(ListChangedEventArgs) OnListChanged(ListChangedEventArgs) OnListChanged(ListChangedEventArgs)

引发 ListChanged 事件。Raises the ListChanged event.

OnPositionChanged(EventArgs) OnPositionChanged(EventArgs) OnPositionChanged(EventArgs) OnPositionChanged(EventArgs)

引发 PositionChanged 事件。Raises the PositionChanged event.

Remove(Object) Remove(Object) Remove(Object) Remove(Object)

从列表中移除指定的项。Removes the specified item from the list.

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

移除此列表中指定索引处的项。Removes the item at the specified index in the list.

RemoveCurrent() RemoveCurrent() RemoveCurrent() RemoveCurrent()

从列表中移除当前项。Removes the current item from the list.

RemoveFilter() RemoveFilter() RemoveFilter() RemoveFilter()

移除与关联的筛选器BindingSourceRemoves the filter associated with the BindingSource.

RemoveSort() RemoveSort() RemoveSort() RemoveSort()

删除具有关联的排序BindingSourceRemoves the sort associated with the BindingSource.

ResetAllowNew() ResetAllowNew() ResetAllowNew() ResetAllowNew()

重新初始化AllowNew属性。Reinitializes the AllowNew property.

ResetBindings(Boolean) ResetBindings(Boolean) ResetBindings(Boolean) ResetBindings(Boolean)

使绑定到 BindingSource 的控件重新读取列表中的所有项,并刷新这些项的显示值。Causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.

ResetCurrentItem() ResetCurrentItem() ResetCurrentItem() ResetCurrentItem()

使绑定到BindingSource重新读取当前选定的项,并刷新其显示的值。Causes a control bound to the BindingSource to reread the currently selected item and refresh its displayed value.

ResetItem(Int32) ResetItem(Int32) ResetItem(Int32) ResetItem(Int32)

使绑定到BindingSource重新读取指定索引处的项,并刷新其显示的值。Causes a control bound to the BindingSource to reread the item at the specified index, and refresh its displayed value.

ResumeBinding() ResumeBinding() ResumeBinding() ResumeBinding()

继续数据绑定。Resumes data binding.

SuspendBinding() SuspendBinding() SuspendBinding() SuspendBinding()

挂起数据绑定,以阻止使用所做的更改对绑定数据源进行更新。Suspends data binding to prevent changes from updating the bound data source.

ToString() ToString() ToString() ToString()

返回包含 Component 的名称的 String(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

(Inherited from Component)

事件

AddingNew AddingNew AddingNew AddingNew

在将项添加到基础列表之前发生。Occurs before an item is added to the underlying list.

BindingComplete BindingComplete BindingComplete BindingComplete

当所有客户端都已绑定到此时发生BindingSourceOccurs when all the clients have been bound to this BindingSource.

CurrentChanged CurrentChanged CurrentChanged CurrentChanged

在当前绑定项更改时发生。Occurs when the currently bound item changes.

CurrentItemChanged CurrentItemChanged CurrentItemChanged CurrentItemChanged

当属性值时发生Current属性已更改。Occurs when a property value of the Current property has changed.

DataError DataError DataError DataError

当货币相关的异常由无提示处理时发生BindingSourceOccurs when a currency-related exception is silently handled by the BindingSource.

DataMemberChanged DataMemberChanged DataMemberChanged DataMemberChanged

DataMember 属性值更改后发生。Occurs when the DataMember property value has changed.

DataSourceChanged DataSourceChanged DataSourceChanged DataSourceChanged

DataSource 属性值更改后发生。Occurs when the DataSource property value has changed.

Disposed Disposed Disposed Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
ListChanged ListChanged ListChanged ListChanged

当基础列表更改或列表中的项更改时发生。Occurs when the underlying list changes or an item in the list changes.

PositionChanged PositionChanged PositionChanged PositionChanged

值之后发生Position属性已更改。Occurs after the value of the Position property has changed.

显式界面实现

IBindingList.AddIndex(PropertyDescriptor) IBindingList.AddIndex(PropertyDescriptor) IBindingList.AddIndex(PropertyDescriptor) IBindingList.AddIndex(PropertyDescriptor)

PropertyDescriptor 添加到用于搜索的索引。Adds the PropertyDescriptor to the indexes used for searching.

IBindingList.RemoveIndex(PropertyDescriptor) IBindingList.RemoveIndex(PropertyDescriptor) IBindingList.RemoveIndex(PropertyDescriptor) IBindingList.RemoveIndex(PropertyDescriptor)

PropertyDescriptor 从用于搜索的索引中移除。Removes the PropertyDescriptor from the indexes used for searching.

ICancelAddNew.CancelNew(Int32) ICancelAddNew.CancelNew(Int32) ICancelAddNew.CancelNew(Int32) ICancelAddNew.CancelNew(Int32)

丢弃集合中挂起的新项。Discards a pending new item from the collection.

ICancelAddNew.EndNew(Int32) ICancelAddNew.EndNew(Int32) ICancelAddNew.EndNew(Int32) ICancelAddNew.EndNew(Int32)

向集合提交挂起的新项。Commits a pending new item to the collection.

ISupportInitialize.BeginInit() ISupportInitialize.BeginInit() ISupportInitialize.BeginInit() ISupportInitialize.BeginInit()

信号BindingSource初始化即将开始。Signals the BindingSource that initialization is starting.

ISupportInitialize.EndInit() ISupportInitialize.EndInit() ISupportInitialize.EndInit() ISupportInitialize.EndInit()

信号BindingSource初始化已完成。Signals the BindingSource that initialization is complete.

ISupportInitializeNotification.Initialized ISupportInitializeNotification.Initialized ISupportInitializeNotification.Initialized ISupportInitializeNotification.Initialized

发生时BindingSource初始化。Occurs when the BindingSource is initialized.

ISupportInitializeNotification.IsInitialized ISupportInitializeNotification.IsInitialized ISupportInitializeNotification.IsInitialized ISupportInitializeNotification.IsInitialized

获取一个值,该值指示是否初始化 BindingSourceGets a value indicating whether the BindingSource is initialized.

Extension Methods

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.

适用于

另请参阅