Click here to Skip to main content
15,176,816 members
Articles / Programming Languages / Visual Basic
Posted 3 Oct 2007


251 bookmarked

Gantt Chart

Rate me:
Please Sign up or sign in to vote.
4.75/5 (80 votes)
2 Oct 2008CPOL2 min read
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

Comments and Discussions

GeneralMy vote of 5 Pin
Member 851706114-Dec-20 6:16
MemberMember 851706114-Dec-20 6:16 
GeneralRe: My vote of 5 Pin
Member 1502299823-Dec-20 4:18
MemberMember 1502299823-Dec-20 4:18 
GeneralRe: My vote of 5 Pin
Member 851706124-Dec-20 22:54
MemberMember 851706124-Dec-20 22:54 
QuestionLoop through bar information for all time in row Pin
Knight school4-Dec-18 10:26
MemberKnight school4-Dec-18 10:26 
GeneralBest Project ever Pin
Member 101946779-Jul-18 8:32
MemberMember 101946779-Jul-18 8:32 
QuestionRefresh bars Pin
Member 1184484022-Jun-18 12:28
MemberMember 1184484022-Jun-18 12:28 
QuestionHow to get the last .totime of the bar, so that the next bar will start in the .totime of the last bar... Pin
Member 1356378822-Dec-17 7:38
MemberMember 1356378822-Dec-17 7:38 
Questionhow to set 8 hours per day Pin
Member 1356378813-Dec-17 11:53
MemberMember 1356378813-Dec-17 11:53 
QuestionHow can i have databind? like this GanttChart1.DataSource = ObjDS.Tables(0) Pin
Member 135637888-Dec-17 14:04
MemberMember 135637888-Dec-17 14:04 
GeneralMy vote of 5 Pin
oli_the_true_one5-Nov-17 7:03
Memberoli_the_true_one5-Nov-17 7:03 
QuestionHow can I add GanttChart3 to the form using Formdesigner Pin
Member 1331203316-Jul-17 5:49
MemberMember 1331203316-Jul-17 5:49 
QuestionHorizontal Scrollbar // Strange Behaviour concerning time Pin
Member 977461413-May-17 6:05
MemberMember 977461413-May-17 6:05 
QuestionControl Pin
Member 300148525-Mar-17 0:28
MemberMember 300148525-Mar-17 0:28 
QuestionIs it possible to use this library in a C# (WPF) project?? Pin
Member 124167409-Mar-17 7:47
MemberMember 124167409-Mar-17 7:47 
QuestionHow can I add a real-time vertical bar into it?? Pin
Member 129744392-Feb-17 7:39
MemberMember 129744392-Feb-17 7:39 
Questionnew value of b.barinformation Pin
Member 387160216-Dec-16 10:11
MemberMember 387160216-Dec-16 10:11 
Questionthee new value of the startime Pin
Member 387160216-Dec-16 10:11
MemberMember 387160216-Dec-16 10:11 
QuestionHow to refresh ChartGantt ? Pin
sylvain_celio26-May-16 0:36
Membersylvain_celio26-May-16 0:36 
AnswerRe: How to refresh ChartGantt ? Pin
chrisbray9-Jun-16 4:10
Memberchrisbray9-Jun-16 4:10 
GeneralRe: How to refresh ChartGantt ? Pin
Member 1208817412-Jan-17 6:49
MemberMember 1208817412-Jan-17 6:49 
GeneralRe: How to refresh ChartGantt ? Pin
Member 1208817412-Jan-17 7:17
MemberMember 1208817412-Jan-17 7:17 
QuestionF-Secure Flags this as a virus Pin
Member 1240640114-Apr-16 3:25
MemberMember 1240640114-Apr-16 3:25 
Questionextend the bar till the end of todate? Pin
billcodes21-Mar-16 3:21
Memberbillcodes21-Mar-16 3:21 
QuestionHow do I add this control to my project? Pin
Tater_Schroeder19-Jan-16 3:28
MemberTater_Schroeder19-Jan-16 3:28 
AnswerRe: How do I add this control to my project? Pin
chrisbray9-Jun-16 4:17
Memberchrisbray9-Jun-16 4:17 

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.