xpo-devexpress-dot-xpo-dot-xpbindingsource-09171c87.md
Gets or sets a data source the XPBindingSource binds to a control.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[DefaultValue(null)]
public object DataSource { get; set; }
<DefaultValue(Nothing)>
Public Property DataSource As Object
| Type | Default | Description |
|---|---|---|
| Object | null |
An object that represents a data source for the XPBindingSource to use.
|
The XPBindingSource component can use data from the following data sources:
The XPBindingSource accepts generic and nongeneric collections.
The XPBindingSource supports most XPO collections fully, for example:
System collections, custom collections, and persistent objects may have the following limitations:
|
Description
|
Result
|
Example
| | --- | --- | --- | |
A data source does not implement at least one of the following: IBindingList or INotifyPropertyChanged.
|
Changes within the data source do not trigger the ListChanged event, because the data source cannot notify the XPBindingSource of any changes.
|
| |
A generic collection does not implement IXPDictionaryProvider.
|
Set the Dictionary or the ObjectClassInfo property manually, because the XPBindingSource cannot acquire the data source’s metadata.
|
| |
A nongeneric collection does not implement IXPClassInfoProvider.
|
Set the ObjectClassInfo property or both the Dictionary and ObjectType properties manually, because the XPBindingSource cannot acquire the data source’s metadata.
|
| |
A data source does not implement IXPSessionProvider.
|
After the XPBindingSource binds a data source to a control, you cannot add new elements to the data source. You can add new elements to a bound data source only within a Session. Sessions are created only for data sources that implement the IXPSessionProvider interface.
|
|
The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
XPO_how-to-bind-data-to-winforms-controls-using-xpbindingsource/CS/DXApplication/Form1.cs#L51
{
IDisposable oldDataSource = ProductListSource.DataSource as IDisposable;
if (oldDataSource != null)
winforms-grid-edit-row-server-mode/CS/BindingListForServerMode/MainForm.cs#L12
private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) {
BindingSource.DataSource = Session.GetLoadedObjectByKey<ServerSideGridTest>(e.Row);
}
XPO_how-to-bind-data-to-winforms-controls-using-xpbindingsource/VB/DXApplication/Form1.vb#L43
Private Sub SetupMainDataSource(ByVal dataSourceType As String)
Dim oldDataSource As IDisposable = TryCast(ProductListSource.DataSource, IDisposable)
If oldDataSource IsNot Nothing Then
winforms-grid-edit-row-server-mode/VB/BindingListForServerMode/MainForm.vb#L14
Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As FocusedRowObjectChangedEventArgs) Handles GridView.FocusedRowObjectChanged
BindingSource.DataSource = Session.GetLoadedObjectByKey(Of ServerSideGridTest)(e.Row)
End Sub
See Also