Deleting a timebar with the Delete Key


This functionality is not currently included directly into the component, but can easily be achieved using a combination of events, methods and properties.  The sample code below is to be placed in either the KeyDown event or KeyUp event of ctSchedule.  The Keycode which is passed into the event is then evaluated.  If the key press is the delete key (keycode 46) and a bar is selected, the DeleteTimeBar method is envoked.  The DeleteTimeBar method deletes a time bar from an item. After a time bar has been deleted, any time bars in that item with an index value greater than that of the deleted bar , will have their index value reduced by a value of 1.

Example:

Private Sub ctSchedule1_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyDelete) And (ctSchedule1.Bar <> 0) Then 'The delete key is pressed and a bar is currently selected
Me.ctSchedule1.DeleteTimeBar Me.ctSchedule1.Selected, Me.ctSchedule1.Bar
End If
End Sub