Click here to Skip to main content
11,704,472 members (49,685 online)
Click here to Skip to main content

Gantt Chart

, 2 Oct 2008 CPOL 295.7K 22K 231
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Adagio.81
Denmark Denmark
No Biography provided

You may also be interested in...

Comments and Discussions

 
Questiongantt chart in c# Pin
rajbir singh thind5-Jul-15 23:33
memberrajbir singh thind5-Jul-15 23:33 
QuestionPl ive me a hint on how to make it to work for 59 seconds or less ! Pin
Renganathan Iyengar30-Apr-15 1:37
professionalRenganathan Iyengar30-Apr-15 1:37 
QuestionHorizontal Scroll Bar Pin
gabriele_greco7-Apr-15 23:29
membergabriele_greco7-Apr-15 23:29 
QuestionHorizontal scroll bar to Gantt Chart Pin
salman ansari2-Mar-15 19:48
membersalman ansari2-Mar-15 19:48 
GeneralMy vote of 5 Pin
AAL87-Nov-14 10:44
memberAAL87-Nov-14 10:44 
SuggestionUpgrade for rectangle bars Pin
Member 1045306330-Oct-14 4:27
memberMember 1045306330-Oct-14 4:27 
QuestionI am getting an error that the control is missing. Pin
Arun KrishnaMoorthy16-Sep-14 21:02
memberArun KrishnaMoorthy16-Sep-14 21:02 
QuestionASP.Net Version of it ?? Pin
benaref24-May-14 23:21
memberbenaref24-May-14 23:21 
QuestionC# Version Webforms Pin
Flavio Renato19-Nov-13 1:23
memberFlavio Renato19-Nov-13 1:23 
AnswerRe: C# Version Webforms Pin
Ingve Moss Liknes21-Mar-14 23:01
memberIngve Moss Liknes21-Mar-14 23:01 
GeneralRe: C# Version Webforms Pin
Member 109619107-Aug-14 20:34
memberMember 109619107-Aug-14 20:34 
Questionhow to add waiting Cursors in your lib Pin
Member 87300737-May-13 16:54
memberMember 87300737-May-13 16:54 
AnswerHow To Add Text to Bars Pin
Famous Mortimer15-Apr-13 9:50
memberFamous Mortimer15-Apr-13 9:50 
QuestionHow to control the column text (need to change the moth to days) Pin
Member 982388314-Apr-13 19:33
memberMember 982388314-Apr-13 19:33 
AnswerRe: How to control the column text (need to change the moth to days) Pin
Adagio.8117-Apr-13 0:50
memberAdagio.8117-Apr-13 0:50 
GeneralMy vote of 5 Pin
doktor0_929-Jan-13 9:23
memberdoktor0_929-Jan-13 9:23 
GeneralRe: My vote of 5 Pin
Adagio.8129-Jan-13 20:52
memberAdagio.8129-Jan-13 20:52 
QuestionSpeed improvement ?! Pin
PSoft200014-Nov-12 3:54
memberPSoft200014-Nov-12 3:54 
QuestionText on Bars Pin
Member 95508663-Nov-12 10:01
memberMember 95508663-Nov-12 10:01 
AnswerRe: Text on Bars Pin
fk_nirvana25-Jun-13 10:52
memberfk_nirvana25-Jun-13 10:52 
QuestionHow to change line height for bars ? Pin
mjfuchs4-Oct-12 1:39
membermjfuchs4-Oct-12 1:39 
AnswerRe: How to change line height for bars ? Pin
Member 95508663-Nov-12 10:12
memberMember 95508663-Nov-12 10:12 
Question1 Question and 1 Error Pin
mjfuchs2-Oct-12 2:06
membermjfuchs2-Oct-12 2:06 
Hello,

i found this an liked it very much. I am using VB 2010 Express and whenn starting the sample it works. but i do get the following message:

Warnung 1 Der Typ "TestApplication.GanttChart" wurde nicht gefunden. Stellen Sie sicher, dass auf die Assembly, die diesen Typ enthält, verwiesen wird. Wenn dieser Typ Teil Ihres Entwicklungsprojekts ist, stellen Sie sicher, dass das Projekt mithilfe der Einstellungen für die aktuelle Plattform oder eine beliebige CPU erstellt wurde. 0 0

My Questions:

How do i get rid off that message because i want to write a deliverable application ?

Where do i find the control object to integrate it in my own applications/forms ?

Are there any references /DLL or anything to load to get the control ?

Greetings Matthias
Questionsignatures on blocks Pin
ibrogim4-Sep-12 1:29
memberibrogim4-Sep-12 1:29 
QuestionC# Version (bug fix help needed) Pin
Orilon1-Sep-12 0:08
memberOrilon1-Sep-12 0:08 
GeneralRe: C# Version (bug fix help needed) Pin
Orilon2-Sep-12 23:59
memberOrilon2-Sep-12 23:59 
Questionadd more rows Pin
woerny24-Jul-12 11:08
memberwoerny24-Jul-12 11:08 
AnswerRe: add more rows Pin
Adagio.8124-Jul-12 19:26
memberAdagio.8124-Jul-12 19:26 
GeneralRe: add more rows Pin
woerny25-Jul-12 10:13
memberwoerny25-Jul-12 10:13 
QuestionAdd a Text Column Pin
mono543218-Jul-12 7:06
membermono543218-Jul-12 7:06 
AnswerRe: Add an other Text Column Pin
mono543213-Aug-12 11:27
membermono543213-Aug-12 11:27 
QuestionFix for Ghost Bar Pin
Goofkop13-Apr-12 1:00
memberGoofkop13-Apr-12 1:00 
QuestionGhost Chart bar? Pin
Goofkop5-Mar-12 4:52
memberGoofkop5-Mar-12 4:52 
QuestionDo you have c# version?? Pin
liusanpi28-Feb-12 16:30
memberliusanpi28-Feb-12 16:30 
AnswerRe: Do you have c# version?? Pin
Member 1098361031-Jul-14 20:12
memberMember 1098361031-Jul-14 20:12 
QuestionI don't know how to use its !! Pin
Highgain29-Jan-12 18:57
memberHighgain29-Jan-12 18:57 
GeneralMy vote of 2 Pin
musthe9930-Dec-11 19:24
membermusthe9930-Dec-11 19:24 
Question5 star Pin
chunk2-Nov-11 4:25
memberchunk2-Nov-11 4:25 
GeneralMy vote of 5 Pin
ralexs26-Aug-11 17:54
memberralexs26-Aug-11 17:54 
Questionnice work mate Pin
cdlitteam24-Aug-11 1:03
membercdlitteam24-Aug-11 1:03 
QuestionNeed C# form source code for studying Pin
rongconmocrang13-Jul-11 0:41
memberrongconmocrang13-Jul-11 0:41 
AnswerRe: Need C# form source code for studying Pin
Adagio.8113-Jul-11 0:50
memberAdagio.8113-Jul-11 0:50 
GeneralRe: Need C# form source code for studying Pin
rongconmocrang15-Jul-11 18:50
memberrongconmocrang15-Jul-11 18:50 
AnswerRe: Need C# form source code for studying Pin
thatraja26-Jan-12 20:42
mvpthatraja26-Jan-12 20:42 
GeneralVery good Pin
Member 392087330-Jun-11 15:33
memberMember 392087330-Jun-11 15:33 
GeneralRe: Very good Pin
Adagio.8113-Jul-11 0:51
memberAdagio.8113-Jul-11 0:51 
QuestionGreat! Pin
Member 801179219-Jun-11 21:59
memberMember 801179219-Jun-11 21:59 
AnswerRe: Great! Pin
Adagio.8113-Jul-11 0:53
memberAdagio.8113-Jul-11 0:53 
GeneralGreat Job.... Pin
sandipm8-May-11 19:31
membersandipm8-May-11 19:31 
GeneralRe: Great Job.... Pin
Adagio.8113-Jul-11 0:55
memberAdagio.8113-Jul-11 0:55 

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.

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