Today I’ll write about a great thing that I’ve found and which saved me a lot of time – one of Microsoft dll’s. Few days ago when I was doing some application for my studies I needed to create a simple Gantt chart showing some data which I’d provide. At the beginning I thought that I’ll have to create my own control, but after a short research(thank you google) I’ve found Microsoft dll which I’ve never heard of. In Windows Forms it’s under the System.Windows.Forms.DataVisualization.Charting namespace and it’s represented by a Chart object.

Dll is available with .NET Framework 3.5 and Visual Studio 2010 or You can also get it from Microsoft download section. It provides various types of charts from simple column, and line to funnel and pyramid. It also has many properties thanks to which You can customize it as You wish.

Below I provide step by step instruction how to make very basic Gantt chart in Windows Forms application:

    1. If You don’t have this dll, download it from here and install it on Your system
    2. If You had to go through step 1., download and install Microsoft Chart Controls Add-On for Visual Studio 2008
    3. Now, in Your VS 2008 You should have a new control named “Chart” under the Data section in the Toolbar
    4. Now, drag it on to a form in the designer mode and open properties window
    5. Select “Series” property and enter the collection
    6. You have “Series1″ added by default. Select it(if it’s not selected), then change the ChartType attribute to RangeBar and click OK button.
    7. Now, go to the *.cs file of the form and type something like this(chart1 is the name property of my Chart object):
      chart1.Series[0].Points.AddXY(1, new object[] { 1, 4 });
      chart1.Series[0].Points.AddXY(1, new object[] { 6, 9 });
      chart1.Series[0].Points.AddXY(2, new object[] { 2, 8 });
    8. Now build Your project and run it to see the results of Your work. It should look something like this:

That’s it! Gantt chart is finished. Of course, if You want it to look better, You should spend some more time customizing it :)

chart1.Series[0].Points.AddXY(1, new object[] { 1, 4 });
chart1.Series[0].Points.AddXY(1, new object[] { 6, 9 });
chart1.Series[0].Points.AddXY(2, new object[] { 4, 8 });