Click here to Skip to main content
Click here to Skip to main content

Gantt Chart

By , 2 Oct 2008
 

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
No Biography provided

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionhow to add waiting Cursors in your libmemberMember 87300737-May-13 16:54 
AnswerHow To Add Text to BarsmemberFamous Mortimer15-Apr-13 9:50 
QuestionHow to control the column text (need to change the moth to days)memberMember 982388314-Apr-13 19:33 
AnswerRe: How to control the column text (need to change the moth to days)memberAdagio.8117-Apr-13 0:50 
GeneralMy vote of 5memberdoktor0_929-Jan-13 9:23 
GeneralRe: My vote of 5memberAdagio.8129-Jan-13 20:52 
QuestionSpeed improvement ?!memberPSoft200014-Nov-12 3:54 
QuestionText on BarsmemberMember 95508663-Nov-12 10:01 
Hi, is there a way to show text on bars permanently?
QuestionHow to change line height for bars ?membermjfuchs4-Oct-12 1:39 
AnswerRe: How to change line height for bars ? [modified]memberMember 95508663-Nov-12 10:12 
Question1 Question and 1 Errormembermjfuchs2-Oct-12 2:06 
Questionsignatures on blocksmemberibrogim4-Sep-12 1:29 
QuestionC# Version (bug fix help needed)memberOrilon1-Sep-12 0:08 
GeneralRe: C# Version (bug fix help needed)memberOrilon2-Sep-12 23:59 
Questionadd more rowsmemberwoerny24-Jul-12 11:08 
AnswerRe: add more rowsmemberAdagio.8124-Jul-12 19:26 
GeneralRe: add more rowsmemberwoerny25-Jul-12 10:13 
QuestionAdd a Text Columnmembermono543218-Jul-12 7:06 
AnswerRe: Add an other Text Columnmembermono543213-Aug-12 11:27 
QuestionFix for Ghost BarmemberGoofkop13-Apr-12 1:00 
QuestionGhost Chart bar?memberGoofkop5-Mar-12 4:52 
QuestionDo you have c# version??memberliusanpi28-Feb-12 16:30 
QuestionI don't know how to use its !!memberHighgain29-Jan-12 18:57 
GeneralMy vote of 2 [modified]membermusthe9930-Dec-11 19:24 
Question5 starmemberchunk2-Nov-11 4:25 
GeneralMy vote of 5memberralexs26-Aug-11 17:54 
Questionnice work matemembercdlitteam24-Aug-11 1:03 
QuestionNeed C# form source code for studyingmemberrongconmocrang13-Jul-11 0:41 
AnswerRe: Need C# form source code for studyingmemberAdagio.8113-Jul-11 0:50 
GeneralRe: Need C# form source code for studyingmemberrongconmocrang15-Jul-11 18:50 
AnswerRe: Need C# form source code for studyingmvpthatraja26-Jan-12 20:42 
GeneralVery goodmemberMember 392087330-Jun-11 15:33 
GeneralRe: Very goodmemberAdagio.8113-Jul-11 0:51 
QuestionGreat!memberMember 801179219-Jun-11 21:59 
AnswerRe: Great!memberAdagio.8113-Jul-11 0:53 
GeneralGreat Job....membersandipm8-May-11 19:31 
GeneralRe: Great Job....memberAdagio.8113-Jul-11 0:55 
GeneralMy vote of 5memberweichiang333-May-11 16:17 
GeneralRe: My vote of 5memberAdagio.8113-Jul-11 0:55 
GeneralI need this code for c#,who can help me to convent this code ?thanks!membercnsdn2-Apr-11 15:09 
GeneralVery good !memberPaulo Viana25-Jan-11 1:13 
GeneralGreat controlmembervliexr28-Oct-10 4:58 
QuestionChange bar with mouse?membervjcoppola22-Jul-10 5:33 
Generalabout ticksmemberkf6130921-Jul-10 9:36 
GeneralVery Nice but missing horizontal scrollbarmemberInvincibleAngel5-Jun-10 9:08 
GeneralRe: Very Nice but missing horizontal scrollbarmemberMicheleLaPietra16-Jun-10 4:12 
GeneralRe: Very Nice but missing horizontal scrollbarmemberAdagio.8117-Jun-10 2:35 
GeneralRe: Very Nice but missing horizontal scrollbarmemberTritonKeyboarder23-Sep-11 1:33 
QuestionHow add Gant Chart ?memberboydevelop21-May-10 5:47 
QuestionIs new version available?memberMember 333222823-Mar-10 0:41 

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

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