This tutorial shows how to use the standard MindFusion.Scheduling dialogs to edit appointments in the calendar. This tutorial extends the application created in the previous tutorial so if you haven't done it already, complete Tutorial 2: Creating Recurrent Items first.
In order to use the stock forms that come with MindFusion.Scheduling, you must first add a reference to the assembly that contains them. To do so, open the Solution Explorer by selecting View -> Solution Explorer from the Visual Studio menu, then right-click on the 'References' item and select 'Add Reference' from the context menu. In the dialog that appears, navigate to the StandardForms.dll file and click 'OK'. The file is usually located in the 'c:\Program Files\MindFusion\MindFusion.Scheduling for WinForms' folder or in the folder where you have installed the product.
The appointment form is usually displayed in response to double-clicking the appointment, so we will handle the ItemClick event of the Calendar control. Switch to design view, select the control and in the Properties window click the 'Events' button located in the toolbar near the top of the window. Navigate to the ItemClick event in the event list and double-click it. That automatically creates an event handler for the event (with default name calendar_ItemClick) and places the input cursor at its beginning.
To display the form add the following code to the body of the event handler just created.
Note |
---|
Be sure to include both MindFusion.Scheduling and MindFusion.Scheduling.WinForms namespace via the using keyword in the beginning of the file. |
C# Copy Code |
---|
// Display the form only if left mouse button is double-clicked |
Visual Basic Copy Code |
---|
' Display the form only if left mouse button is double-clicked |
The form automatically updates the edited item with all modifications made by the user, except when the user clicks the 'Delete' button. In this situation the form doesn't do anything except that it returns DialogResult.Abort. It is a responsibility of the developer to remove the item from the schedule.
If the item is not a recurring one, we can simply remove it from the Items collection. If the item is a recurring item, then it is not within the collection and an attempt to remove it will result in exception. To mark a recurring item as deleted we invoke MarkException on the corresponding Recurrence object, passing to it a reference to the item as the first argument and true as the second argument.
Compile and run the application. Create an appointment by typing and then double-click it to display the appointment dialog.