Click here to Skip to main content
Licence CPOL
First Posted 3 Oct 2007
Views 159,259
Downloads 6,157
Bookmarked 203 times

Gantt Chart

By | 2 Oct 2008 | Article
Adds an easy to use Gantt chart to your application.

GanttChart.JPG

Introduction

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.

Background

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)
  toolTipText.Add("Time:")

  .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:

GanttChart2.SaveImage("C:\TestImage.jpg")

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

History

  • 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.

License

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

About the Author

Adagio.81



Denmark Denmark

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionFix for Ghost Bar PinmemberGoofkop1:00 13 Apr '12  
QuestionGhost Chart bar? PinmemberGoofkop4:52 5 Mar '12  
QuestionDo you have c# version?? Pinmemberliusanpi16:30 28 Feb '12  
QuestionI don't know how to use its !! PinmemberHighgain18:57 29 Jan '12  
GeneralMy vote of 2 [modified] Pinmembermusthe9919:24 30 Dec '11  
Question5 star Pinmemberchunk4:25 2 Nov '11  
GeneralMy vote of 5 Pinmemberralexs17:54 26 Aug '11  
Questionnice work mate Pinmembercdlitteam1:03 24 Aug '11  
QuestionNeed C# form source code for studying Pinmemberrongconmocrang0:41 13 Jul '11  
AnswerRe: Need C# form source code for studying PinmemberAdagio.810:50 13 Jul '11  
GeneralRe: Need C# form source code for studying Pinmemberrongconmocrang18:50 15 Jul '11  
AnswerRe: Need C# form source code for studying Pinmvpthatraja20:42 26 Jan '12  
GeneralVery good PinmemberMember 392087315:33 30 Jun '11  
GeneralRe: Very good PinmemberAdagio.810:51 13 Jul '11  
QuestionGreat! PinmemberMember 801179221:59 19 Jun '11  
AnswerRe: Great! PinmemberAdagio.810:53 13 Jul '11  
GeneralGreat Job.... Pinmembersandipm19:31 8 May '11  
GeneralRe: Great Job.... PinmemberAdagio.810:55 13 Jul '11  
GeneralMy vote of 5 Pinmemberweichiang3316:17 3 May '11  
GeneralRe: My vote of 5 PinmemberAdagio.810:55 13 Jul '11  
GeneralI need this code for c#,who can help me to convent this code ?thanks! Pinmembercnsdn15:09 2 Apr '11  
GeneralVery good ! PinmemberPaulo Viana1:13 25 Jan '11  
GeneralGreat control Pinmembervliexr4:58 28 Oct '10  
QuestionChange bar with mouse? Pinmembervjcoppola5:33 22 Jul '10  
Generalabout ticks Pinmemberkf613099:36 21 Jul '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web01 | 2.5.120517.1 | Last Updated 2 Oct 2008
Article Copyright 2007 by Adagio.81
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid