Defining Columns and Column Types in ctMDays


The ctMDay control can be set up with multiple columns. These columns can be defined as either dates, or user defined column codes. The column type can be changed with the ColumnAppType property.

The maximum number of columns that may be displayed in the control is 10. However, the control is able to host additional columns beyond 10. If the column type is set to dates, the number of hosted columns is determined by the VirtualColumns property. If the column type is set to codes, the number of hosted columns is determined by the number of columns added to the control using the AddHeader method.

By default, the columns are set up to handle dates. The date for the first column is determined by the Date property. The DisplayColumns property determines the number of visible columns and the VirtualColumns property determines the number of hosted columns. If the VirtualColumns property value is greater than the DisplayColumns property value, a horizontal scroll bar will appear at the bottom of the control so that the user can move to the non-visible columns in the control.

As stated, columns can also be set up to handle different codes. This can be useful if you want to schedule groups of people for a single day, instead of scheduling a single person for many days. To set the columns up to be defined as codes, set the ColumnAppType property to a value of 1. The column must then be defined using the AddHeader method.

The example below illustrates how to add column headers and then to add appointments to the column:

Dim nIndex As Integer
 
Me.ctMDay1.ColumnAppType = 1 'Define the column as "code"
Me.ctMDay1.DisplayColumns = 2 'Display 2 columns in the component
 
nIndex = Me.ctMDay1.AddHeader(200, "Dr. Johnson") 'Define the first column
nIndex = Me.ctMDay1.AddHeader(300, "Dr. Smith") 'Define the second column
 
'The following will add a Key Appointment, this method is always recommended so that you can define the unique key
nIndex = Me.ctMDay1.AddKeyAppointment(240, 300, Me.ctMDay1.Date, "Test Appointment", 12345678)
Me.ctMDay1.AppointCode(nIndex) = 200 'Assign the appointment to a column
End Sub

The AddHeader method accepts a column code and the text to be displayed in the column header. All column codes must be unique. They are used to connect an appointment to its proper column. When a new appointment is created from the control, the selected columns column code will be assigned to the appointment.