Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Collapse]Scheduler
   [Expand]Product Information
   [Collapse]Getting Started
     Lesson 1 - Create a Simple Scheduling Application
     Lesson 2 - Create a Simple Scheduling Application with DateNavigator
     Lesson 3 - Provide Bar UI for a Scheduler
     Lesson 4 - Provide Ribbon UI for a Scheduler
     Lesson 5 - Bind a Scheduler to MS SQL Database at Design Time
     Lesson 6 - Bind a Scheduler to MS Access Database at Design Time
     Lesson 7 - Create a Custom Appointment Edit Form
     Lesson 8 - Implement a Custom Inplace Editor
   [Expand]Fundamentals
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Lesson 6 - Bind a Scheduler to MS Access Database at Design Time

The following example demonstrates how to bind a SchedulerControl to an MDB database at design time in Microsoft Visual Studio.

To bind the SchedulerControl to a BindingSource, follow the instructions below.

Expanded Create a Database

  1. Create a new Microsoft Access database. Name it SchedulerTest.accdb.
  2. Create Appointments and Resources tables as described in the Scheduler Data Source - Microsoft Access Database topic.
  3. Add three records to the Resource table using the following SQL query syntax. Each Insert statement should be run as a separate query.
  4. Insert a bitmap image into the Picture field for each record in the Resources table. To accomplish this, open the Resources table in the Datasheet View, right-click the Picture field ans select Insert Object... A dialog window appears. Select Create New, Bitmap Image as the Object Type. After clicking OK the Paint Resource Editor is invoked. Click Paste, Paste From and select an image file to load.

Expanded Create Data Objects

  1. Create a new Windows Forms Application project in Visual Studio.

  2. Drop the BindingSource component from the Data Toolbox tab to the form. A new component (bindingSource1) will appear in the tray.

  3. Select the bindingSource1 component in the tray and open the Properties window (for instance, by pressing the F4 key or by selecting VIEW | Properties Window in the main menu). Then click the drop-down arrow for the DataSource property and select Add Project Data Source....

    The Data Source Configuration Wizard will be invoked.

  4. Select the Database icon and click Next.

  5. On the next page, select the Dataset database model and click Next.

  6. On the next page, click New Connection button and specify the path to the database in the Add Connection dialog window.

  7. Click Next on the following page, which asks you whether the connection string created should be saved to the configuration file.

  8. The next page allows you to choose which tables need to be obtained from the database. Select the Appointments and Resources tables and click Finish.

  9. Visual Studio automatically adds an instance of the schedulerTestDataSet class to the tray when connecting to the database in the manner shown above. You can check whether or not the generated dataset contains the "Appointments" and "Resources" tables. To do this, double-click SchedulerTestDataSet1.xsd in Solution Explorer or select the schedulerTestDataSet component in the tray and click the Edit in DataSet Designer... task.

    The data schema will be opened, as shown below.

Expanded Bind the Scheduler to Data

  1. Drop the SchedulerControl item from the DX.17.2: Scheduling Toolbox tab to the form.

  2. Click the smart tag icon at the top right of the control () to display its actions list. Select Dock in Parent Container. This will stretch the SchedulerControl to fill the entire form.

  3. The new SchedulerStorage component (schedulerStorage1) is automatically added to the form and assigned to the Scheduler Control (using the SchedulerControl.Storage property). The SchedulerStorage component implements all data operations for the SchedulerControl class. Hence, to bind a scheduler to data, it is necessary to provide data for the storage to which it is assigned.

    Appointment data is stored in the Appointments data table. This data should be provided to the AppointmentStorage, which is accessed via the SchedulerStorage.Appointments property. To bind the storage, set its DataSource property to the Appointments data table in bindingSource1.

  4. Specify standard mappings for appointment properties. Click the smart tag of the SchedulerControl to invoke the SchedulerControl Tasks menu, and click the Mappings Wizard... link in the Appointments section to display the Mappings Wizards.

    In the Setup Appointment Storage window, click the Generate button. All required mappings are generated automatically. Check to see if they are correct, and click Finish.

    Note

    Make sure that fields are not mapped more than once. Use the Check Mappings link in the Appointments section of the SchedulerControl Tasks menu to prevent this. Incorrect or missed mappings may result in errors that are difficult to trace when they occur.

    For more information on the mappings concept, see the Mappings topic.

  5. Click the smart tag of the SchedulerControl to invoke the SchedulerControl Tasks menu. Click the Resource Data Source drop-down arrow and select the Cars data table.

  6. Now specify standard mappings and custom mappings for resource properties. Click the Mappings Wizard... link in the Resources section. In the Setup Resource Storage window, click the Generate button. All required mappings are generated automatically. Set the ParentId mapping to none, since it is only required for the Gantt View. Click Finish.

Expanded Provide Data at Runtime

To retrieve data from the database, call the Fill method of the corresponding TableAdapter. In this example, the SchedulerTestDataSet.Appointments and SchedulerTestDataSet.Resources tables are populated with data using the Fill methods of the AppointmentsTableAdapter and ResourcesTableAdapter objects. Microsoft Visual Studio automatically adds this code to the form's Load event. In most cases, you do not need to add it manually or modify it.

Show Me

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

Expanded Set Initial Scheduler Options

  • Change the Start Date

    By default, the start date of the scheduler is set to the date set in the system when the scheduler was created. Change it to the current date.

  • Group Appointments by Resource

    To group the scheduler data by resource, set the SchedulerControl.GroupType property value to SchedulerGroupType.Resource.

  • Set the Number of Displayed Resources

    If there are too many resources in the ResourceStorage, the scheduler area looks cluttered. To avoid this, use the SchedulerViewBase.ResourcesPerPage property to specify the number of resources shown on the screen at one time.

  • Enable Shared Resources

    To enable an appointment to have several associated resources, set the AppointmentStorageBase.ResourceSharing property to true.

  • Customize the Appearance of Resource Headers

    To control how resource headers are displayed within the SchedulerControl, use the properties of the SchedulerResourceHeaderOptions object, accessed via the SchedulerOptionsView.ResourceHeaders property. To specify the size and size mode of images that are shown within resource headers in the following way.

Expanded Post Data Back to the Database

  1. Run the project and start editing data. The changes will be saved in the underlying DataTable objects, but they will not be saved in the database. To complete the example, write the code that posts the changes back to the database. Handle the SchedulerStorageBase.AppointmentsChanged, SchedulerStorageBase.AppointmentsDeleted and SchedulerStorageBase.AppointmentsInserted events, and include the code that saves changes to the event hander, as illustrated in the following code snippet.

    Show Me

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

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

    Show Me

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

Expanded Observe the Result

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

Show Me

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

How would you rate this topic?​​​​​​​