In this section you'll learn how to use the basic Scheduler for WinForms functionality to create a simple scheduling application. This section is not intended to be a comprehensive tutorial of all features of Scheduler for WinForms, but rather provide a quick introduction and highlight some general approaches to using the product.
In the following quick start guide, you'll create a simple scheduling application and customize its appearance, bind your scheduling application to a data source, customize the calendar, and explore some of the run-time functionality Scheduler for WinForms provides.
C# |
Copy Code
|
---|---|
DataTable dt = new DataTable(); string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"ComponentOne Samples\Common\C1NWind.mdb") + ";"; OleDbConnection conn = new OleDbConnection(connectionString); OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Appointments", conn); adapter.Fill(dt); |
C# |
Copy Code
|
---|---|
//Bind Scheduler to the datatable
c1Schedule1.DataStorage.AppointmentStorage.DataSource = dt;
|
C# |
Copy Code
|
---|---|
c1Schedule1.DataStorage.AppointmentStorage.DataMember = "Appointments";
|
C# |
Copy Code
|
---|---|
c1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName = "Properties"; // Bind the Body property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.Body.MappingName = "Body"; // Bind the End property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.End.MappingName = "End"; // Bind the IdMapping property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName = "Id"; // Bind the Location property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.Location.MappingName = "Location"; // Bind the Start property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.Start.MappingName = "Start"; // Bind the Subject property to a field c1Schedule1.DataStorage.AppointmentStorage.Mappings.Subject.MappingName = "Subject"; |
C# |
Copy Code
|
---|---|
// c1Schedule1.CalendarInfo.StartDayTime = new TimeSpan(10, 0, 0); c1Schedule1.CalendarInfo.EndDayTime = new TimeSpan(21, 0, 0); c1Schedule1.CalendarInfo.TimeInterval = C1.C1Schedule.TimeScaleEnum.FifteenMinutes; c1Schedule1.CalendarInfo.TimeScale = new TimeSpan(9000000000); c1Schedule1.CalendarInfo.WeekStart = DayOfWeek.Monday; |
In this step you'll create a simple scheduling application using the C1Calendar and C1Schedule controls. You'll then customize the appearance of your scheduling application using the incorporated Smart Designers and without adding any code to your project.
To begin, complete the following steps:
A simple schedule application in week view with a three-month calendar using a predefined Visual Style will appear.
You have successfully created a simple scheduling application without writing a single line of code. In the next step, you'll learn how to bind the C1Schedule control to a data source.
In the last step you created a simple scheduling application. In this step you'll walk through binding a data source to the scheduling application you created in the Creating the Scheduling Application topic.
To bind the C1Schedule control to a data source, complete the following steps:
C# |
Copy Code
|
---|---|
// TODO: This line of code loads data into the 'appointmentsDS.Appointments' table. You can move, or remove it, as needed. this.appointmentsTableAdapter.Fill(this.appointmentsDS.Appointments); |
C# |
Copy Code
|
---|---|
this.appointmentsTableAdapter.Update(this.appointmentsDS.Appointments); |
Notice that the data from the Appointments table is reflected in both the C1Calendar and C1Schedule controls.
By default, the Office 2007 Visual Style gives you added navigation options by enabling the navigation panels and the browse buttons. If an appointment is not present in the visible range of dates, a navigation panel appears on the left and right sides of the schedule. Clicking on one of the panels changes the current view to the previous or next date with appointments. If there is not a previous or next appointment, the corresponding panel is disabled. You can also use the navigation buttons to navigate through the schedule. The navigation buttons appear on the Title bar of the C1Schedule control. Clicking on one of the navigation buttons changes the current view to the next or previous range of dates. You have successfully bound the scheduling application to a data source. In the next topic, you will learn how to customize calendar settings for a 10-hour day, four-day work week.
The following steps will walk you through setting up the calendar for a 10-hour day, four-day work week, including setting the start day time, end day time, the time scale, and week start properties. Complete the following to customize the calendar:
C# |
Copy Code
|
---|---|
this.c1Schedule1.CalendarInfo.StartDayTime = new TimeSpan(10, 0, 0); this.c1Schedule1.CalendarInfo.EndDayTime = new TimeSpan(21, 0, 0); |
C# |
Copy Code
|
---|---|
this.c1Schedule1.CalendarInfo.TimeInterval = C1.C1Schedule.TimeScaleEnum.FifteenMinutes;
|
OR
C# |
Copy Code
|
---|---|
this.c1Schedule1.CalendarInfo.TimeScale = new TimeSpan(9000000000); |
C# |
Copy Code
|
---|---|
this.c1Schedule1.CalendarInfo.WeekStart = DayOfWeek.Monday;
|
The scheduling application displays a 4-day work week when in the Work Week view.
Congratulations! You have successfully set the calendar settings for a 10-hour day, four-day work week. This concludes the Quick Start.