How to Build a C# .NET Scheduler Windows App
Quick Start Guide | |
---|---|
What You Will Need |
Visual Studio 2022 |
Controls Referenced | |
Tutorial Concept | This blog is part one of our Scheduler series which covers how to create a Windows Appointment Management application for handling doctors' schedules. We will model it after a real-world healthcare application for managing client appointments. |
In today’s fast-paced world, effective appointment management is crucial for both personal and professional success. Whether you’re a busy professional, a small business owner, or managing a team, optimizing your scheduling process can save time and enhance productivity. An effective scheduling system not only helps with appointment management but also improves communication.
ComponentOne provides the C1Scheduler control to achieve complete appointment scheduling functionality in your .NET desktop applications. This control is a fully functional Outlook-style schedule that allows users to add, edit, group, and manage their appointments.
In this blog, part one of ComponentOne’s Scheduler series, we will learn how to create a Doctors Scheduler Windows app for managing appointments using the C1Scheduler control. This sample is designed as a real-world healthcare provider application for managing appointments.
We will develop the Scheduler Management app by following the steps below:
- Setup the WinForms Project
- Create the Scheduler and Calendar UI
- Create C# Model Classes for Appointment and Doctor
- Data Bind and Group the Scheduler
Ready to check it out? Download ComponentOne Today!
Setup the WinForms Project
Let’s start by creating a WinForms project in Visual Studio 2022 and adding the required dependencies by following the steps below:
- Open Visual Studio and select File>New>Project.
- Search “winforms” in the search box and select the “Windows Forms App (.Net Framework)” option. Then, click the “Next” button.
- Enter the project name, project location, solution name, and framework. Then, click “Next.”
- Add the C1Scheduler NuGet package by following the steps below:
a. In the Solution Explorer, right-click on the project and select “Manage NuGet packages...”
Now, we have a WinForms project with all the required NuGet packages.
Create the Scheduler and Calendar UI
In this section, we will build the healthcare application user interface.
- Add a SplitContainer in Form1.cs[Design] by dragging and dropping it from the toolbox. Name the SplitContainer “splitContainer1.”
- Set FixedPanel = Panel1 of splitContainer1. Then, resize the width of Panel1 per the requirement for a Calendar UI and CheckList of doctors.
- Add another SplitContainer inside Panel1 of splitContainer1. Name this SplitContainer “splitContainer2.”
- Set Orientation=Horizontal for splitContainer2.
- Set FixedPanel = Panel1 of splitContainer2. Then, resize the height of Panel1 to fit a Calendar UI.
At this point, the UI will appear as below:
- Next, drag and drop a C1Scheduler control from the toolbox into the right panel. Then, set Dock=Fill for the C1Scheduler. Name the C1Scheduler “appointmentScheduler.”
- Add a C1Calendar control from the toolbox into the top left panel. Then, set Dock=Fill and Schedule=appointmentScheduler to bind the two controls.
- Add a Label to the bottom left panel. Set its Text= “List of Doctors:”
- Add a CheckedListBox control to the bottom left panel. Then, set Anchor=Top, Bottom, Left on CheckedListBox and resize it over the panel.
Finally, the UI will appear as below:
Create C# Model Classes for Appointment and Doctor
Next, we will create some model classes, such as Appointment and Doctor, to represent our data collections. These model classes inherit the INotifyPropertyChanged interface so that they can bind with our scheduler data storage. The C1Scheduler Data Storage requires an INotifyPropertyChanged interface.
Below is the C# code for the Appointment and Doctor classes:
Doctor class:
Data Bind and Group the Scheduler
In this section, we will learn how to fetch the data from JSON and bind it to the scheduler’s DataStorage, create the list of doctors, and group the scheduler by doctor.
In the constructor of Form1, add the code below to fetch and bind existing appointments from an Appointments.json file and doctors from the Doctors.json file.
Setup the List of Doctors
Now, we have a list of doctors, and it's time to set up the list that will display them in the CheckListBox. This will allow users to hide or show doctors based on their checked state. The collection of doctors was added to the OwnerStorage of the scheduler. Follow the steps below to set up the doctors CheckListBox:
- Add all doctors to the CheckListBox:
- Check all items of CheckListBox:
- Handle the ItemCheck event of CheckListBox to update the visible grouping in C1Scheduler.
Group the Doctors in C1Scheduler
One of the key features of C1Scheduler is its capability for resource grouping. This allows us to view schedules in a grouped view where the group can be any contact, resource, room, etc. In this case, we will group the scheduler by doctor. Follow the steps below in your code to enable scheduler grouping.
Enable grouping by specifying how to group the scheduler and setting the GroupBy property. You can also listen to the BeforeGroupHeaderFormat event to customize the group header UI. See the code below:
Add Appointments to the Scheduler
Finally, we will add some sample appointments to populate the schedule. We can also adjust the scheduler’s visible dates by setting the SelectedDates property on C1Calendar.
Ready to try it yourself? Download ComponentOne Today!
Conclusion
The first part of our Doctors Scheduler Windows app has been developed. We hope this blog helps you create a custom scheduling management application using C1Scheduler. Feel free to customize it further to fit your requirements. You can download the full sample to try it yourself.
When you build and run the sample, it will appear as below:
To learn more about the C1Scheduler control, you can check out the documentation.