Back to Devexpress

WorksheetDataBindingCollection.BindToDataSource(Object, Int32, Int32) Method

officefileapi-devexpress-dot-spreadsheet-dot-worksheetdatabindingcollection-dot-bindtodatasource-x28-system-dot-object-system-dot-int32-system-dot-int32-x29.md

latest4.9 KB
Original Source

WorksheetDataBindingCollection.BindToDataSource(Object, Int32, Int32) Method

Binds the worksheet cell range to the specified data source.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
WorksheetDataBinding BindToDataSource(
    object dataSource,
    int rowIndex,
    int columnIndex
)
vb
Function BindToDataSource(
    dataSource As Object,
    rowIndex As Integer,
    columnIndex As Integer
) As WorksheetDataBinding

Parameters

NameTypeDescription
dataSourceObject

A data source object whose data should be retrieved into the worksheet.

| | rowIndex | Int32 |

An integer that is the row index of the top left cell in the binding range.

| | columnIndex | Int32 |

An integer that is the column index of the top left cell in the binding range.

|

Returns

TypeDescription
WorksheetDataBinding

A WorksheetDataBinding object that contains information about the data-bound range.

|

Remarks

The method uses default values of the ExternalDataSourceOptions object.

The following code snippets (auto-collected from DevExpress Examples) contain references to the BindToDataSource(Object, Int32, Int32) method.

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.

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/CS/WpfSpreadsheet_BindToDataSource/MainWindow.xaml.cs#L38

csharp
// Load data from the "Suppliers" data table into the worksheet starting from the cell "B12".
    sheet.DataBindings.BindToDataSource(dataSet.Suppliers, 11, 1);
}

winforms-spreadsheet-bind-to-ms-sql-server-database/CS/SuppliersExample/Form1.cs#L32

csharp
// Load data from the "Suppliers" data table into the worksheet starting from the cell "B12".
    sheet.DataBindings.BindToDataSource(dataSet.Suppliers, 11, 1);
}

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/VB/WpfSpreadsheet_BindToDataSource/MainWindow.xaml.vb#L39

vb
' Load data from the "Suppliers" data table into the worksheet starting from the cell "B12".
    sheet.DataBindings.BindToDataSource(dataSet.Suppliers, 11, 1)
End Sub

winforms-spreadsheet-bind-to-ms-sql-server-database/VB/SuppliersExample/Form1.vb#L35

vb
' Load data from the "Suppliers" data table into the worksheet starting from the cell "B12".
    sheet.DataBindings.BindToDataSource(dataSet.Suppliers, 11, 1)
End Sub

See Also

Data Binding in WinForms Spreadsheet Control

DataBindings

Error

WorksheetDataBindingCollection Interface

WorksheetDataBindingCollection Members

DevExpress.Spreadsheet Namespace