The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

IObjectDataSourceValidationService Interface

Allows custom validation of the ObjectDataSource data sources before using them in the document.

Namespace: DevExpress.XtraSpreadsheet.Services

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

public interface IObjectDataSourceValidationService
Public Interface IObjectDataSourceValidationService
public interface IObjectDataSourceValidationService
Public Interface IObjectDataSourceValidationService

Remarks

The ObjectDataSource can cause an undesired behavior when retrieving its data. This may be unacceptable in certain situations. You can use the SpreadsheetControlOptions.DataSourceOptions option to specify whether to prohibit the ObjectDataSource data retrieval, prompt the user or silently load the data. To prompt the user, the WinForms SpreadsheetControl calls the ObjectDataSourceValidationService.Validate method of the default IObjectDataSourceValidationService implementation. However, you can implement your own service with a custom IObjectDataSourceValidationService.Validate method to replace the default service. A custom service can be also registered for the non-visual Workbook instance, which has no default service.

Examples

Imports DevExpress.DataAccess.ObjectBinding
Imports DevExpress.XtraSpreadsheet.Services
            If barCheckCustomValidationService.Checked Then
                spreadsheetControl1.ReplaceService(Of IObjectDataSourceValidationService)(New MyObjectDataSourceValidationService())
            Else
                spreadsheetControl1.ReplaceService(Of IObjectDataSourceValidationService)(New ObjectDataSourceValidationService(spreadsheetControl1))
            End If
    Public Class MyObjectDataSourceValidationService
        Implements IObjectDataSourceValidationService

        Public Sub Validate(ByVal dataSources As IEnumerable(Of ObjectDataSource)) Implements IObjectDataSourceValidationService.Validate
            ' Do nothing to allow loading.
            ' Clear the DataSource and DataMember properties to prohibit loading.
            For Each ds As ObjectDataSource In dataSources
                ds.DataSource = Nothing
                ds.DataMember = Nothing
            Next ds
        End Sub
    End Class
See Also