This tutorial shows how to programmatically filter and group appointments using MindFusion.Scheduling for ASP.NET.
Read Adding the control tutorial for detailed instructions on how to create a web site and add the Calendar control to it. Follow the steps in Tutorial 1: Creating appointments to add contacts, locations and appointments.
For the purpose of this tutorial add a ListBox control and three buttons to the page. Set the ListBox's ID to 'lbContacts' and its SelectionMode property to 'Multiple'. Set the buttons' Text property to 'Apply filter', 'Apply grouping' and 'Clear grouping/filtering'.
Switch to code view and add the following code at the end of CreateScheduleData method:
C#
![]() |
---|
//fill the list of contacts |
Visual Basic
![]() |
---|
'fill the list of contacts |
This code adds the contacts, created in Tutorial1 to the ListBox control. We will use them to select by which resource(s) the Calendar will be filtered or grouped.
Double click on the first (Apply filter) button and in the code-behind add the following code to its Click handler:
C#
![]() |
---|
//clear the contacts //add the selected contacts to the Calendar's Contacts collection |
Visual Basic
![]() |
---|
'clear the contacts |
This code gets all contacts, which are selected in the ListBox and adds them to the Calendar's Contacts collection. Finally it sets the GroupType property of the Calendar to GroupType.FilterByContacts.
Double click on the second (Apply grouping) button and in the code-behind add the following code to its Click handler:
C#
![]() |
---|
//clear the contacts |
Visual Basic
![]() |
---|
'clear the contacts |
This code gets all contacts, which are selected in the ListBox and adds them to the Calendar's Contacts collection. Finally it sets the GroupType property of the Calendar to GroupType.GroupByContacts.
Double click on the last (Clear grouping/filtering) button and in the code-behind add the following code to its Click handler:
C#
![]() |
---|
Calendar1.Contacts.Clear(); |
Visual Basic
![]() |
---|
Calendar1.Contacts.Clear() |
The code above will remove any existing filtering or grouping by setting the Calendar's GroupType property to GroupType.None.
Run the web page. The image below depicts what the page output would look like when the Calendar is grouped by both contacts: