Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 3.77 KB

File metadata and controls

46 lines (30 loc) · 3.77 KB

WPF Spreadsheet: How to Bind a Worksheet to a Generic List or a BindingList Data Source

This example demonstrates the use of List, BindingList, and ReadOnlyCollection objects as data sources to bind data to the worksheet range.

image

Implementation Details

The WorksheetDataBindingCollection.BindToDataSource method is called to create the binding.

The ExternalDataSourceOptions object specifies various data binding options. A custom converter with the IBindingRangeValueConverter interface converts weather data between the data source and a worksheet. 

If the data source does not allow modification (ReadOnlyCollection<T>), the binding worksheet range also prevents modification. To modify the data obtained from the read-only data source, use the WorksheetExtensions.Import method instead of data binding.

Note

The use of the WorksheetExtensions.Import method in production code (and referencing the DevExpress.Docs assembly) requires a license to the DevExpress Document Server or the DevExpress Universal Subscription.

Data binding error fires the WorksheetDataBinding.Error event and cancels the data update. The event handler in this example displays a message containing the error type.

Files to Review

C# Visual Basic
MainWindow.xaml MainWindow.xaml
MainWindow.xaml.cs MainWindow.xaml.vb
MyConverter.cs MyConverter.vb
WeatherReport.cs WeatherReport.vb

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)