Skip to main content Skip to footer

How to Programmatically Trigger the Split Task Tool in GanttView

When implementing a custom toolbar or ribbon control for GanttView, you may need to add a custom "Split Task" button to allow users to split selected schedule tasks into sub-segments. Since the split task mode is managed internally by the control's built-in toolbar, finding a direct API method to toggle this tool programmatically is not immediately obvious.

Solution
To trigger the task split functionality programmatically from a custom button click or ribbon command, access the built-in "Split Task" toolstrip item directly through the GanttView.ToolStrip collection and invoke its PerformClick() method.

Invoking PerformClick() places the mouse cursor into split mode, allowing the user to click on a selected task bar on the schedule chart to divide it into multiple task segments.

' Programmatically trigger the internal Split Task tool from a custom button click
Private Sub btnSplitTask_Click(sender As Object, e As EventArgs) Handles btnSplitTask.Click
    ' Locate the "Split Task" button inside the built-in ToolStrip collection
    Dim splitButton As ToolStripItem = ganttView.ToolStrip.Items("btnSplitTask")
    
    ' Invoke PerformClick to activate the task splitting cursor mode
    If splitButton IsNot Nothing Then
        splitButton.PerformClick()
    End If
End Sub