Q: I am storing all of my appointment recurrence and exception data into an SQL server database. Is there a way to manually create exceptions for my recurrences?

A: Exceptions can be created from code using the Recurrence.MarkException(Item, bool) method. You must provide a reference to the item occurrence, which will be marked as an exception. In order to obtain a single instance of a recurring item, call Recurrence.GenerateItems method.

Q: If I create an appointment and set a remainder object, at specified time it doesn't work!

A: Reminders in Planner.NET raise an event. In order to be notified for a reminder, you must handle Schedule.ItemReminderTriggered. Assuming that the variable 'calendar' references a Planner.NET calendar control, the code below shows how the event could be handled:

calendar.Schedule.ItemReminderTriggered += 
   new MindFusion.Scheduling.ItemEventHandler(OnItemReminder);

// ...

private void OnItemReminder(object sender, 
   MindFusion.Scheduling.ItemEventArgs e)
{
  MessageBox.Show(e.Item.Reminder.Message);
}

Q: How can I add my own property to the Appointment class? I need to keep two data values.

A: In order to add custom data to an appointment, you need to create your own class derived from Appointment. You can add whatever additional properties you need to the derived class.

The sample below demonstrates how to do this.

class MyAppointment : Appointment
{
  public MyAppointment()
  {
    customData = 5;
  }  
  public int CustomData
  {
    get { return customData; }
    set { customData = value; }
  }  
  private int customData;
}

Use the Calendar.InteractiveItemType property to specify that items from your class should be instantiated whenever the user creates items interactively. In this case, you have to ensure that your class provides a constructor without parameters as stated in the Planner.NET documentation.

Note: Check Tutorial #4 in the documentation for more information on how to create custom appointment classes that also support serialization, recurrence and duplication.

Q: I need to set the fill color of an item to a specific color based on the status of the item within single month and timetable views. Is there a calendar level attribute that may be used for this?

A: Try to set the Brush property of the Style object associated with the item? For example, if 'item' is a variable referencing the Item whose background color you would like to change, here is a sample code that should do this:

item.Brush = MindFusion.Drawing.SolidBrush(Color.Green);
You should use the SelectedStyle.Brush to change the fill color of selected items.

Q: Can you please tell me how to get the index of an item in the Timetable view. I use my own ID numbers and tags out of a database and need to delete an item, the only way that I can see to do this is if I have the index number. Can you please tell me how to get the index or how to delete the item from its ID or tag.

A: The items are stored in a collection, which can be accessed from the Calendar.Schedule.Items property. To find the index of a particular item within that collection, simply call the IndexOf method of the collection. You can also traverse this collection and remove from it the item, which meets certain criteria (like having particular tag or id).

Q: How can the color for appointments be adjusted in the resource view?

A: The items in Resource view use Style.HeaderBrush to fill their contents.

Q: Is it possible to double-click an open space in the calendar view and pop up an Appointment window to create an event?

A: You can handle the DateClick event and display the appointment creation window in it. You can check the Clicks property of the corresponding event data object to determine the number of times the mouse button was pressed. A value of 2 means that the button was double-clicked.

Q: How can I easily limit the number of simultaneously appointments? I want to create an automatic system to create appointments. When the user starts dragging, I want to limit the number of concurrent appointments.

A: The following method prevents users from dragging more than 3 appointments in a single day in a Single Month, List or WeekRange views. The method represents a handler of the Calendar.ItemModifying event, which is fired whenever the user moves or resizes appointments. Setting the Confirm property of the supplied EventArgs object forbids the operation.

private void calendar_ItemModifying(object sender, 
   ItemModifyConfirmEventArgs e)
{
 DateTime from = e.NewStartTime.Date;
 DateTime to = from + new TimeSpan(TimeSpan.TicksPerDay - 1); 
 while (to < e.NewEndTime.Date)
 {
  if (calendar.Schedule.GetAllItems(from, to).Count > 2)
  {
   e.Confirm = false;
   return;
  }  
  from += TimeSpan.FromDays(1);
  to = from + new TimeSpan(TimeSpan.TicksPerDay - 1);
 }
}