[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Collapse]Scheduler (legacy)
   [Expand]Getting Started
   [Expand]Visual Elements
    [Collapse]Data Binding
      How to: Bind a Scheduler to MS Access Database (Part 1) (legacy)
      How to: Bind a Scheduler to MS Access Database (Part 2) (legacy)
      How to: Bind a Scheduler to Data via ObjectDataProvider (legacy)
      How to: Create a Custom Field for an Appointment (legacy)
      How to: Filter Appointments (legacy)
      How to: Filter Resources (legacy)
    [Expand]Data Exchange
    [Expand]Date and Time
    [Expand]Initial Settings
    [Expand]Range Control
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Bind a Scheduler to MS Access Database (Part 1) (legacy)


You are viewing documentation for the legacy WPF Scheduler control. If you're starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

This example consists of the following sections.

Expanded Create a New Project and Add a Scheduler Control

  1. Create a new WPF Application project, specify its name as MyWpfApplication, and open the MainWindow.xaml file in the Designer.
  2. Add the SchedulerControl item to your project. For this, double-click the SchedulerControl item from the DX.18.2: Scheduling group. Specify CarSchedulingControl as the name of the newly added SchedulerControl.

  3. Set the HorizontalAlignment and VerticalAlignment property values to Stretch. This will stretch the scheduler control to fill the entire window.

    Your XAML may look like the following. (If it does not, you can overwrite your code with the code below.)


    You can add a SchedulerControl by overwriting your MainWindow.xaml file with this code without dragging the SchedulerControl control to the window. However, in this case, you will need to manually add references to the following libraries: DevExpress.Data.v18.2, DevExpress.Xpf.Core.v18.2, DevExpress.Xpf.Scheduler.v18.2, and DevExpress.XtraScheduler.v18.2.Core.

    Normally, when adding references to these assemblies, you should select them from the Global Assembly Cache (GAC). However, if you prefer to copy them locally, or need to include them in your product installation later, you can find copies in the C:\Program Files (x86)\DevExpress 18.2\Components\Bin\Framework\ directory.

Since the most common way of using a scheduler is to bind it to a datasource, proceed to the next step to learn how.

Expanded Create Data Objects

In the next step, you will bind the scheduler to the CarScheduling table of the CarsDB database. The scheduler will represent this table as appointments.

  1. Copy the CarsDB.mdb file to the directory of your project. By default, this file is placed in the C:\Users\Public\Documents\DXperience 18.2 Demos\Data directory.
  2. Include the CarsDB.mdb file in the project by right-clicking the file, and selecting Include In Project in the invoked context menu. This will invoke the Data Source Configuration Wizard.


    If the CarsDB.mdb is not displayed in the Solution Explorer, select Show All Files from the Project menu or click the Show All Files icon () in the Solution Explorer toolbar.

  3. In the invoked window, select the Dataset database model and click Next.

  4. The next page allows you to choose tables to be obtained from the database. Select the CarScheduling table and click Finish.

  5. As a result, Visual Studio will generate a set of classes that support ADO.NET architecture. The main classes include:

    • CarSchedulingDataTable - represents a System.Data.DataTable object that will contain records from the "CarScheduling" table in the Cars database;
    • CarsDBDataSet - represents a System.Data.DataSet object (a collection of tables that can be related to each other). The generated DataSet contains the CarSchedulingDataTable table;
    • CarSchedulingTableAdapter - represents a TableAdapter object that can communicate with the "CarScheduling" table in the Cars database.
  6. Visual Studio automatically adds a dataset schema when connecting to the database in the manner illustrated above (the CarsDBDataSet.xsd node in Solution Explorer). You can check to see whether the dataset generated contains the CarSchedulingDataTable table. To do this, double-click CarsDBDataSet.xsd to open the designer.

Next, bind the SchedulerControl to data and establish mappings between the fields in data tables and appointment properties.

Expanded Bind the Scheduler to Data

In this example, all appointment data is stored in the CarScheduling data table. This data should be provided to AppointmentStorage, which is accessed via the SchedulerStorage.AppointmentStorage property. To bind the storage, set the SchedulerControl.Storage.AppointmentStorage.DataSource property to the CarScheduling data table.

You will also need to populate the underlying CarSchedulingDataTable table with data from the database. To do this, use the Fill method of the CarSchedulingTableAdapter object.

Expanded Specify Mappings

Next, specify standard mappings for appointment properties by setting the AppointmentStorage.Mappings property values as shown below.

Your XAML may look like the following. (If it does not, you can overwrite your code with the code below.)

Expanded Customize the Scheduler

Change the Start Date - The SchedulerControl object allows you to set the start date for which the scheduler will initially show data after the project is run. To do this, set the Start property of SchedulerControl to 7/15/2010.

Changing the Active View - Initially, the SchedulerControl displays its data using the Day View. But in this instance, you will need to manipulate many appointments over several months. Here, the most appropriate view is either the Week View or the Month View. Set the ActiveViewType property value of SchedulerControl to Week.

Your XAML may look like the following. (If it does not, you can overwrite your code with the code below.)

Expanded Post Data Back to the Database

At this stage, you can run the project and start editing data. The changes will be saved to the underlying DataTable object, but they will not be saved in the database. To complete this example, write the code that posts the changes in the CarSchedulingDataTable table back to the database. The SchedulerStorage.AppointmentsChanged, SchedulerStorage.AppointmentsDeleted and SchedulerStorage.AppointmentsInserted events should be handled for this purpose.

To avoid a concurrency exception when saving data to a database, update the Identifier column value of the newly created data table record. To accomplish this, handle the RowUpdated event of the table adapter.

To complete the example, use the following code:

Expanded Result

Run the project. The following image shows the application at runtime.

Expanded See Also


A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2493.

Is this topic helpful?​​​​​​​