ComponentOne Scheduler for WinForms
Assigning Predefined Categories to an Appointment
Working with Scheduler for WinForms > Appointments > Categories > Assigning Predefined Categories to an Appointment

Categories can be assigned in code or at run time through the Categories dialog box. The following code, added to the Form_Load event, assign the Strategies category to an appointment:

To write code in Visual Basic

Visual Basic
Copy Code
' Add an appointment        
Dim app As C1.C1Schedule.Appointment        
app = Me.C1Schedule1.DataStorage.AppointmentStorage.Appointments.Add()
 
' Set some details for the appointment.         
app.Subject = "Meeting"        
app.Location = "Large Conference Room"        
app.Duration = TimeSpan.FromMinutes(45)        
app.Start = New Date(2007, 2, 28, 13, 30, 0)
   
' Assign a category to the appointment.         
Dim category As C1.C1Schedule.Category        
category = Me.C1Schedule1.DataStorage.CategoryStorage.Categories.Item(15)        
app.Categories.Add(category)

To write code in C#

C#
Copy Code
// Add a new appointment.         
C1.C1Schedule.Appointment app;         
app = this.c1Schedule1.DataStorage.AppointmentStorage.Appointments.Add(); 

// Set some details for the appointment.         
app.Subject = "Meeting";         
app.Location = "Large Conference Room";         
app.Duration = TimeSpan.FromMinutes(45);         
app.Start = new DateTime(2007, 2, 28, 13, 30, 0); 
 
// Assign a category to the appointment.         
C1.C1Schedule.Category category;         
category = this.c1Schedule1.DataStorage.CategoryStorage.Categories[15];         
app.Categories.Add(category);

At run time, assigning a category or categories to an appointment can be done through the Categories dialog box. Clicking the Categories button in the Appointment dialog box opens the Categories dialog box.

In the Categories dialog box, you can check the categories you would like to add to the appointment.