ActiveReports 19 .NET Edition
MESCIUS.ActiveReports.Design.Win Assembly / GrapeCity.ActiveReports.Design Namespace / Designer Class / LocateDataSource Event
Example

In This Topic
    LocateDataSource Event (Designer)
    In This Topic
    Occurs when a data provider of the previewed report needs to locate the data at runtime.
    Syntax
    'Declaration
     
    Public Event LocateDataSource As LocateDataSourceEventHandler
    public event LocateDataSourceEventHandler LocateDataSource
    Event Data

    The event handler receives an argument of type LocateDataSourceEventArgs containing data related to this event. The following LocateDataSourceEventArgs properties provide information specific to this event.

    PropertyDescription
    The data returned by the event handler.  
    Gets the report's GrapeCity.ActiveReports.PageReportModel.IDataSet object to locate data for.  
    Gets the Parameters collection specified for a given report instance.  
    Gets the Report that is trying to locate the data set.  
    Remarks
    This event is triggered when the report requires a data source that has not been predefined or needs to be resolved at runtime. It allows for the dynamic provision of data sources based on the report's requirements or user input.

    Event handlers can use this opportunity to present data source selection dialogs, perform custom data source configuration, or apply logic to determine the appropriate data source for the current context.

    Example
    Utilize the specified event to supply data necessary for the preview functionality of page reports. This ensures that the report previews are populated with the latest data.
    designer.LocateDataSource += (sender, args) => {
    	var dataSourceName = args.DataSet.Query.DataSourceName;
    	var dataSource = ((PageReport)designer.Report).Report.DataSources.First(x => x.Name == dataSourceName);
    	if(dataSource.ConnectionProperties.DataProvider == "OBJECT")
    	{
    	    args.Data = new[] { new { CustomerName = "Gc Inc." } };
    	}
    };
    See Also