.NET C# Winforms Gantt Chart Control

Last Update: September 10, 2014This blog post is updated for Gantt Chart Control 1.3.

Project Description
The .NET C# Winforms Gantt Chart Control is a class library project hosted on codeplex that provides a quick way to get a gantt chart up and running for your application.

This control was first developed as part of a report writing task. At that time of writing the report, I did not have at hand a software like Microsoft Project but I still needed to show a gantt chart. Hence I ended up “drawing” my chart in code as it was the faster alternative than drawing it in, say, Photoshop or PowerPoint as repeated edit changes were dynamic and fast.

As such, this winforms control will be suitable if you just need simple features for a larger application or for prototyping purposes. Hopefully, I can add more features to the control to make it more robust in time to come.

The doxygen documentation provides a full list of “developer” API you can refer to. However, as a user you only need to read the following interfaces to see what the user API offers:

Code examples are included in the downloads. More code examples will be provided here in due time.

Basic Use Case

public Form1() {

    // create a project manager
    var manager = new ProjectManager();
    // create built-in task or use your own derived task
    var task = new Task() { Name = "Hello World"; };
    // add the task to the manager
    // create a chart control
    var chart = new Chart();
    // initialise the chart with the manager
    // add chart to the form controls collection.

    // throughout your own code, call chart.Invalidate()
    // where you expect updates to the drawn chart,
    // to tell the chart to Paint() itself.

Gantt Chart Control


  • Time unit independant data structure specification
  • Chart can be customised in various ways to draw in different time scales, grid size, font, colors and shapes.
  • Single tasks, grouped tasks, sub tasks, precedent tasks, split tasks
  • Percentage complete property for each task and group
  • Various mouse events for customising advance mouse UI experience directly on the chart.
  • Printing to file
  • Set tool tip for show/hide during mouseover and mouseout on tasks.
  • Programatically scroll to particular date/time (horizontall) or task (vertically)
  • Shows slack and critical paths

Feature requests and fixes are welcomed through discussion page. Thank you for your contributions.

Mouse Commands

The control comes with a default set of mouse commands for quickly creating and editing the gantt chart.

  • Left Click – Select task
  • SHIFT + Left Click – Select multiple tasks
  • Left Mouse Drag – Change task starting point
  • Right Mouse Drag – Change task duration
  • Middle Mouse Drag – Change task complete percentage
  • Left Double Click – Toggle collaspe on task group
  • Right Double Click – Split task into task parts
  • Left Mouse Dragdrop onto another task – Group dragged task under dropped task
  • Right Mouse Dragdrop onto another task part – Join task parts
  • SHIFT + Left Mouse Dragdrop onto another task – Make dragged task a successor of dropped task
  • ALT + Left Mouse Dragdrop onto another task – Ungroup dragged task from dropped task / Remove successor – predecessor relationship
  • SHIFT + Left Mouse Dragdrop – Reorder tasks
  • SHIFT + Middle Click on task – Create new task under the clicked task
  • ALT + Middle Click – Delete Task

These commands can be modifed by using various code contructs e.g. event listeners or inheritance (method overrides).

Setup / Installation
GanttChart does not require any dependencies. Simply add the DLL to your project, or add the GanttChart project to your solution and add the reference to the project.

Object Classes
The API exposes 3 main classes, Project, Chart and  Task

  • The Project is where the data i.e. Tasks and their relationships are specified.
  • The Chart is a UserControl responsible for visualising the Project, in this case, presents it as a Gantt Chart.
  • The Task is a data structure caching schedule information. A Task with sub task is a task group.

The ProjectManager class provides logic for managing Tasks and provides analytic information regarding the project schedule such as Critical Paths (Although that’s the only thing worth mentioning at the moment. Will add more in the future). ProjectManager is the logic layer and you can design UI controls on top of Project for visualisation, for example a Work Breakdown Structure, Histogram etc. The Gantt Chart control is one such UI that is currently in this project.

The Chart class is responsible for turning the data in Project into graphics for visualisation and for user to graphically interact with it, thereby performing edits on the underlying Project data. It is also our objective to design Chart in a way where customisation of its look and feel should be as simple as possible. Hence Chart provides events both for input (mouse and keyboard) and paint events in which users can listen to and plug in code as approperiate. For a complete modification, it is also possible to derive a specialised class from Chart and implement your own custom methods.

The Task resides in ProjectManager, in associative structures representing their relationships with each other and their resources. Internally, ProjectManager calculates and caches schedule information in Task for chart to lookup and draw. Custom Tasks can be dervied and added to ProjectManager to store your own custom application logic or allow other controls such as PropertyGrid to manipulate its properties.

Custom Drawing Coordinate System

If you are extending the control for more customise drawing, either by listening to paint events or creating a derived chart and overriding paint methods, this section is for you, as you may find that things are not drawing at the location you tell it to.

The display of drawings (Tasks, headers, columns etc.) on the Control is treated in a specialised manner to overcome Winforms controls size limits and also to simplify the moving of drawing from the application to print and other devices.

Gantt Chart Control Coordinate System

The entire surface of the chart is in an imaginary area where the top left corner is the origin representing the ProjectManager.Start date. All the task have time schedules relative to the start date and resides on the imaginary surface of the chart. All the tasks when drawn, are drawn onto this coordinate space called chart-coordinates.

A Viewport hovers above the chart and moves about in this chart coordinates. The Viewport captures all the images of tasks and relations directly under it and within its boundary, known as a Viewport.Rectangle. Everything else is culled away. It then calculates the Header information and columns that should appear at the top of its Rectangle and sticks it there.

In the next step, the Viewport projects and squeezes all of its contents onto a device, such as the Winforms control or a piece of printing paper, thereby producing the image you see on the device. The device has its own coordinate system where in the case of the winforms control, the top left is (0, 0) regardless of the Viewport location in chart-coordinate space. Hence, when the mouse reports its location on the device, the mouse device-coordinates cannot be used directly, to locate items in the chart-coordinate space.

In the normal use case, all these coordinate conversions would have been taken care of, and all you need to do is to specify points and rectangles in chart-coordinate space, with the only exception of drawing billboards. Once Chart.BeginBillboardMode() is called, all points and rectangles will be drawn in device-coordinate space until Chart.EndBillboardMode() is called.