The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Filter an SQL Query at Runtime in the WinForms Viewer

Note

This example demonstrates API and functionality that is common for the DashboardViewer and DashboardDesigner controls.

The following example shows how to filter an SQL query at runtime using the DashboardViewer.CustomFilterExpression event. The CustomFilterExpressionEventArgs.TableName event parameter is used to check the name of the query that should be filtered. The CustomFilterExpressionEventArgs.FilterExpression property specifies the required filter criteria.

using DevExpress.DataAccess;
using DevExpress.Data.Filtering;

namespace Dashboard_CustomFilterExpression_Win {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();

            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
        }

        private void dashboardViewer1_CustomFilterExpression(object sender, CustomFilterExpressionEventArgs e) {
            if (e.DataSourceName == "SQL Data Source 1" && e.TableName == "Invoices") {
                e.FilterExpression = new BinaryOperator("CustomerID","AROUT",BinaryOperatorType.Equal);
            }
        }
    }
}
See Also