Navigation bar
  Home Print document Start Previous page
 107 of 234 
Next page End  

Gravitybox Schedule Primer
Page 105 
1998-2004 Gravitybox Software LLC
until the MaxDate of the schedule. All appointments will be created on a Monday. Since
the WeekInterval is set to “1”, an appointment will be created every week.
Now that recurring appointments can be created, there is a question, “How can we
remove the collection of them?” As always there are two ways to remove appointments:
in code or with user interaction. To remove a group of appointments in code, the
“RemoveRecurrence” method of the ScheduleItems collection may be used. This
method receives two parameters. The first is an existing appointment object, or its key,
index, or GroupId. Any one of these may be used to determine the GroupId. The second
parameter determines if the specified appointment is removed along with all of its
recurrences. If the first parameter is a GroupId the second parameter is ignored.
However if the first parameter is an object, index, or key; the second parameter play a
significant role. If you wish to remove all occurrences of an appointment but not the
original appointment itself then set the second parameter to false; otherwise set it to
true.
Another way to remove an appointment’s recurrences is to use the provided GUI. Under
normal circumstances when the user highlights an appointment and presses the
<Delete> key, he is prompted to remove the selected appointment. If the appointment is
part of a group, the prompt changes and asks the user if he wishes to remove the entire
series of appointments or the single, selected one. This assumes that the
“AllowRecurrences” property is set. If it is not set, the schedule does not recognize
groups. Even when there are multiple appointments with the same GroupId the delete
prompt will not change since the schedule is configured to ignore groups completely.
The Recurrence object’s state may be saved if need be. It
contains the methods “ImportXML” and “ExportXML”. The
ImportXML method takes an XML, string parameter and
loads the object from it. The ExportXML will return the XML state of the object. You may
use these methods to load and store the recurrence pattern from and to a string. This
may be useful in the certain situations. The ScheduleRecurrence control has a
Recurrence object on it. When the control is loaded, its object has the default state. You
may wish to load a previous state. An example of the usefulness of these methods is
illustrated as follows. Put a ScheduleRecurrence control on a form. When the form is
load the user can set each property to some value. Now the user unloads the form and
the control along with it of course. If the user loads this form again, he will probably
expect his settings from the last time to be restored. This does not happen “auto-
magically”. In the form unload event you can store the string from the
ScheduleRecurrence control’s ExportXML method in a string somewhere. On the load
event of the form, you can use the ImportXML method to restore the previous state of
the control that the user set. This is exactly what happens in the background on the
ScheduleProperties control. When the user presses the “Recurrences” button on this
control, a form is loaded with a ScheduleRecurrence control. Each time the button is
pressed the previous state of the recurrence pattern is displayed.
Quick Tip
Dump the recurrence information to
an XML string or file for later use with
the object’s “ExportXML” method.
http://www.purepage.com