Click here to Skip to main content
13,085,936 members (88,535 online)
Click here to Skip to main content
Add your own
alternative version


239 bookmarked
Posted 3 Oct 2007

Gantt Chart

, 2 Oct 2008
Rate this:
Please Sign up or sign in to vote.
Adds an easy to use Gantt chart to your application.



This component makes it easy to add a Gantt chart to your application. You just need three lines of code to get it working.

This Gantt chart control includes these features:

  • The columns are automatically shown based on the width of the component and the time between the start date and the end date. If there're more than two days between those dates, it will only show the date; otherwise, it will show the time of the day (with minimum 5 minutes apart).
  • You can set the color (including the hover color) for each bar individually.
  • The Gantt chart automatically shows a custom scroll bar when it contains more rows than the visible area allows.
  • You can easily obtain information about the bar when hovering your mouse above one.
  • An easy to use multi-row tooltip text.
  • Change bars using your mouse.


I tried to find a good, free, and easy Gantt chart control to use in my project, but didn't have any luck. Then, I decided to make one myself, which actually was easier than I thought it would be.

Using the code

To get the Gantt chart component to show something, you only need this:

GanttChart1.FromDate = New Date(2007, 12, 12, 0, 0, 0)
GanttChart1.ToDate = New Date(2007, 12, 24, 0, 0, 0)
GanttChart1.AddChartBar("Row 1", Nothing, New Date(2007, 12, 12), 
    New Date(2007, 12, 16), Color.Aqua, Color.Khaki, 0))

As mentioned above, this component also includes a multi-line tooltip text.

With GanttChart2
  Dim toolTipText As New List(Of String)

  .ToolTipTextTitle = .MouseOverRowText
  .ToolTipText = toolTipText
End With

When a tooltip-text-row is included, the line is automatically bolded.

It is also possible to save the Gantt Chart to an image file:


The included Zip file contains a project showing how to use its different features.


  • Version 0.55
    • Added the feature to drag the bars (after editing a bar, a BarChanged event is fired).
    • If time between start and end date is larger than 60 days, the Gantt chart switches over to showing months instead of days.
  • Version 0.54
    • The Gantt chart can now be saved to an image file.
  • Version 0.53
    • ScrollBar added to component.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Denmark Denmark
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionSpeed improvement ?! Pin
PSoft200014-Nov-12 3:54
memberPSoft200014-Nov-12 3:54 
Why two almost identical for loops ?

The bar is not yet needed!!!

The foreach Loop is needless

The Speed will increase dramatically Wink | ;)

Optimised version:

Private Sub DrawNetHorizontal(ByVal grfx As Graphics)
        Dim FUN As String = "DrawNetHorizontal"
        Dim index As Integer = 0
        Dim width As Integer = 0
            If shownHeaderList Is Nothing Then Exit Sub
            If shownHeaderList.Count = 0 Then Exit Sub
            index = 0
            width = (widthPerItem * shownHeaderList.Count) + barStartLeft
            For index = 0 To GetIndexChartBar("QQQQQQ")
                    grfx.DrawLine(lineColor, 0, barStartTop + (barHeight * index) + (barSpace * index), width, barStartTop + (barHeight * index) + (barSpace * index))
                Catch EXC As Exception
                End Try
            lastLineBottomStop = barStartTop + (barHeight * (index - 1)) + (barSpace * (index - 1))
        Catch EXC As Exception
        End Try
    End Sub



General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 2 Oct 2008
Article Copyright 2007 by Adagio.81
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid