Copyright 1999-2009 by eXontrol

www.exontrol.net
Getting Started

The eXSuite package contains more than 40 components, with over 200 objects, 9,000 functions, and more than 3,000,000 lines of source code... Available as: /COM /NET /WPF, 32, 64 bits

Getting started with the component

If you had a first sight on the component's documentation and you will like using it, you can follow the next steps to see how to add the component to a form, adding code, and handing events. This tutorial will guide how to start programming the eXG2antt component, similar for other components as well. If the NET Assembly is listed in the programming language name it means that the section is applied to NET Assembly Version of the component, else the COM or ActiveX version is being used.

The tutorial shows adding and using the component for the following programming languages:

  • Access
  • VB6
  • VFP
  • VB.NET
  • C#
  • C++
  • C++ Builder
  • Delphi
  • Clarion

The following tutorials show:

The first thing we need is to be able to insert the component to a form, dialog or window.
  • Access. Click the More Controls icon in the Toolbox, locate and select the ExG2antt Chart ActiveX Control in the shortcut menu being opened. Click the form and drag the cursor to a new position, so the control is being inserted to your form.
  • VB6. Select the Project\Components (CTRL+T) and locate the ExG2antt Control Library, check it, and click the OK button. The G2antt icon shows in the Toolbox, double click it or select and put it to your form.
  • VFP. Select Tools\Options\Controls and locate the ExG2antt Chart ActiveX Control in Selected list box. Check it, and click the Set As Default, then click OK. The ExG2antt icon is shown in the Form Controls toolbox, click it, so the cursor is changed, go to the for and put it ( click and drag the cursor to a new position ).
  • VB.NET ( ActiveX version ). Right click the Toolbox, select the Choose Items,  and then select the COM Components page, locate the ExG2antt Chart ActiveX Control, check it, and click ok. The toolbox includes the ExG2antt Chart ActiveX Control icon, double click it.
  • VB.NET ( NET Assembly ). Right click the Toolbox, select the Choose Items,  and then select the .NET Framework Components page, click the Browse button, so the Open file dialog is shown. Locate the exontrol.exg2antt.dll ( usually it goes to the C:\Program Files\Exontrol\ExG2antt.NET folder ), select it, and click OK, so the .NET Framework Components list displays a new checked items called exg2antt. Click ok. The toolbox includes the exg2antt icon, double click it.
  • C# ( ActiveX version ). Right click the Toolbox, select the Choose Items,  and then select the COM Components page, locate the ExG2antt Chart ActiveX Control, check it, and click ok. The toolbox includes the ExG2antt Chart ActiveX Control icon, double click it.
  • C# ( NET Assembly ). Right click the Toolbox, select the Choose Items,  and then select the .NET Framework Components page, click the Browse button, so the Open file dialog is shown. Locate the exontrol.exg2antt.dll ( usually it goes to the C:\Program Files\Exontrol\ExG2antt.NET folder ), select it, and click OK, so the .NET Framework Components list displays a new checked items called exg2antt. Click ok. The toolbox includes the exg2antt icon, double click it.
  • C++ (6.0). Select the dialog where you need to insert the control. Right click, and select the  Insert ActiveX control, locate and select the ExG2antt Chart ActiveX Control and then click ok. Select the Properties of the Dialog, and click the Styles page, and check the Clip siblings and Clip children styles. This will prevent flickering when the form is resized. Invoke the MFC ClassWizard ( CTRL + W, or select the control and then right click, and the select ClassWizard item in the shortcut menu ), click the Member Variables page, select the IDC_G2ANTT1 identifier in the Control IDs list, and click the Add Variable ... button, so a member variable is added. Confirm the classes going to be added to your project and select OK. Specify the name of the member variable being inserted as m_g2antt for instance. Click OK, and the Close the MFC ClassWizard, by clicking again the OK button.
  • C++ (2005,2008). Select the dialog in design mode, where you need to insert the control, in the Resource \ Dialog section. Right click, and select the  Insert ActiveX control, locate and select the ExG2antt Chart ActiveX Control and then click ok. The control is automatically added to your dialog. In the same time, you can change the Clip Children and Clip Siblings properties of the dialog, so the control inside will not flicker when resizing the form or the dialog. Select the control in design mode, and then right click, and select the Add Variable shortcut menu, specify the name of the variable to be created ( Variable name field ), m_g2antt1 for instance, and then click Finish button.
  • C++ Builder (2009). Select the "Component \Import Component..." and then "Import ActiveX Control" or "Import .NET Assembly", depending on what version you are about to import. If ActiveX, select the ExG2antt Control Library from the list of "Registered ActiveX Controls", and then click Next. You will be informed of the "Generated import file", Check the "Generate Component Wrappers", Click Next, and select "Install To New Package" , Click Next, and type the name of the new package as being exg2antt, Click Finish. The exgantt.bpl package is generated and installed. Select the Form where you want to insert the component, and then locate the TG2antt in the ActiveX section of the IDE's Tool Palette. Double click it or drag it to your form, so the component will be inserted to the form. Activate the Project that contains the form, so you can run it, else the Package will be activated, for which  you will be asked for parameters to run. Note that in case you are importing the /NET Assembly of the control, you must click Add in the "Import Component" dialog, and locate the file exontrol.exg2antt.dll ( usually it goes to the C:\Program Files\Exontrol\ExG2antt.NET folder ).
  • Delphi (2009). Select the "Component \Import Component..." and then "Import ActiveX Control" or "Import .NET Assembly", depending on what version you are about to import. If ActiveX, select the ExG2antt Control Library from the list of "Registered ActiveX Controls", and then click Next. You will be informed of the "Generated import file", Check the "Generate Component Wrappers", Click Next, and select "Install To New Package" , Click Next, and type the name of the new package as being exg2antt, Click Finish. The exgantt.bpl package is generated and installed. Select the Form where you want to insert the component, and then locate the TG2antt in the ActiveX section of the IDE's Tool Palette. Double click it or drag it to your form, so the component will be inserted to the form. Activate the Project that contains the form, so you can run it, else the Package will be activated, for which  you will be asked for parameters to run. Note that in case you are importing the /NET Assembly of the control, you must click Add in the "Import Component" dialog, and locate the file exontrol.exg2antt.dll ( usually it goes to the C:\Program Files\Exontrol\ExG2antt.NET folder ).
  • Clarion. Put OCX control on Window, name it like ?Gantt. At window.Init, put this code: ?Gantt{PROP:Create} = 'Exontrol.G2antt.1\!XXXXXXXX' where XXXXXXXX is runtime license, OR - Put OCX control on Window, name it like ?Gantt. Under Object type: enter Exontrol.G2antt.1, under Storage type: enter something like this: Gantt.prp\!GanttProperty. Then you can use Propertis of Gantt contril, but must distribute Gantt.prp

Resizes the component in the form, save the project and run the form to see it running. At this time, the control is not initialized, so it should look like follows:

Now, let's add some code in order to have some items inside. The sample adds a single column and two items. Go Back.
  • Access. In design mode, select the component, open the properties and changes the name from ActiveXCtl1 to G2antt1. Select again the component, right click, and select the "Build Events".  Select the Form in the left drop down, so the Form_Load event is added. Copy and paste the following code:
Private Sub Form_Load()
    Dim g As EXG2ANTTLib.G2antt
    Set g = G2antt1.Object
    With g
        .Columns.Add ("Tasks")
        With .Items
            .AddItem "Task 1"
            .AddItem "Task 2"
        End With
    End With
End Sub
  • VB6. In design mode, double click the form, so the Form_Load event is added and add the following code:
Private Sub Form_Load()
    With G2antt1
    .Columns.Add ("Tasks")
    With .Items
        .AddItem "Task 1"
        .AddItem "Task 2"
    End With
    End With
End Sub
  • VFP. In design mode, double click the form, and select the Init in the Procedure drop down, so the Form1_Init is added as follow:
with thisform.G2antt1
	.Columns.Add("Tasks")
	with .Items
		.AddItem("Task 1")
		.AddItem("Task 2")
	endwith
endwith
  • VB.NET ( ActiveX version ). In design mode, double click the form so the Form1_Load event is added, and copy the following code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With AxG2antt1
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
    End With
End Sub
  • VB.NET ( NET Assembly ). In design mode, double click the form so the Form1_Load event is added, and copy the following code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With Exg2antt1
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
    End With
End Sub
  • C# ( ActiveX version ). In design mode, double click the form so the Form1_Load event is added, and copy the following code:
private void Form1_Load(object sender, EventArgs e)
{
    axG2antt1.Columns.Add("Tasks");
    axG2antt1.Items.AddItem("Task 1");
    axG2antt1.Items.AddItem("Task 2");
}
  • C# ( NET Assembly ). In design mode, double click the form so the Form1_Load event is added, and copy the following code:
private void Form1_Load(object sender, EventArgs e)
{
    exg2antt1.Columns.Add("Tasks");
    exg2antt1.Items.AddItem("Task 1");
    exg2antt1.Items.AddItem("Task 2");
}
  • C++ (6.0).  Search for the OnInitDialog function and add the code:
m_g2antt.GetColumns().Add("Tasks");
m_g2antt.GetItems().AddItem( COleVariant( "Task 1" ) );
m_g2antt.GetItems().AddItem( COleVariant( "Task 2" ) );
  • C++ (2005,2008). The #import <exg2antt.dll> must be called somewhere in your code, so the EXG2ANTTLib namespace is defined. By default, the class wizard add a class definition for the main object only, not for all objects that the component may expose. Using the #import you can import the entire type library. Now, search for the OnInitDialog method and add the following code:
EXG2ANTTLib::IColumnsPtr spColumns = m_g2antt.get_Columns();
spColumns->Add(_T("Tasks"));
EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
spItems->AddItem( _T("Task 1") );
spItems->AddItem( _T("Task 2") );
  • C++ Builder (2009). Once you imported the component, the IDE automatically added wrapper classes for all objects of the component. Handle the FormCreate event and add the code:
    IColumnsPtr spColumns = G2antt1->Columns;
    spColumns->Add( L"Tasks", TNoParam() );
    IItemsPtr spItems = G2antt1->Items;
    spItems->AddItem( TVariant("Task 1") );
    spItems->AddItem( TVariant("Task 2") );
  • Delphi (2009). Handle the FormCreate event and add the code:
    with G2antt1 do
    begin
      Columns.Add('Tasks');
      with Items do
      begin
        AddItem('Task 1');
        AddItem('Task 2');
      end;
    end;
  • Clarion. Handle the embed code on Window init (after open window) or under Button embed:
    ! Data
    lc:Columns    ANY
    lc:Items      ANY
    mc:Chart      ANY
    h1            ANY
    h2            ANY
    
    ! Code
    lc:Columns = ?Gantt{'Colums'}
    lc:Items   = ?Gantt{'Items'}
    ?Gantt{lc:Columns&'.Add("Task")'}
    ?Gantt{lc:Items&'.AddItem("Task 1")'}
    ?Gantt{lc:Items&'.AddItem("Task 2")'}

Once these have been added, you can save and run the project again and you should get the following result

  and previous

Now, once we have columns, and items being added, let's start working on the chart area so we can get displayed some bars. So, we need to go back to the form initialization so we can call properties and methods of the chart object. The red code just changes the first visible date in the chart, and layout the control's chart on 2 levels first displaying the month, and the second level displaying the  days.

  • Access. Open the form in design mode, go to "Build Event" and add the red section to the Form_Load event:
Private Sub Form_Load()
    Dim g As EXG2ANTTLib.G2antt
    Set g = G2antt1.Object
    With g
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
        End With
        .Columns.Add ("Tasks")
        With .Items
            .AddItem "Task 1"
            .AddItem "Task 2"
        End With
    End With
End Sub
  • VB6. Go to the Form_Load event and adds the red section
Private Sub Form_Load()
    With G2antt1
		With .Chart
			.FirstVisibleDate = #1/1/2008#
			.LevelCount = 2
			With .Level(0)
				.Label = "<b><%mmmm%></b> <%yyyy%>"
				.Unit = exMonth
			End With
			.Level(1).Label = "<%d%>"
		End With
		.Columns.Add ("Tasks")
		With .Items
			.AddItem "Task 1"
			.AddItem "Task 2"
		End With
    End With
End Sub
  • VFP. Go to the the Form1_Init method and adds the red code as follow:
with thisform.G2antt1
	With .Chart
		.FirstVisibleDate = {^2008-1-1}
		.LevelCount = 2
		With .Level(0)
			.Label = "<b><%mmmm%></b> <%yyyy%>"
			.Unit = 16
		EndWith
		.Level(1).Label = "<%d%>"
	EndWith
	.Columns.Add("Default")
	with .Items
		.AddItem("Task 1")
		.AddItem("Task 2")
	endwith
endwith
  • VB.NET ( ActiveX version ). Go back to the Form1_Load event and add the red code as shown bellow:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With AxG2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = EXG2ANTTLib.UnitEnum.exMonth
            End With
            .Level(1).Label = "<%d%>"
        End With
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
    End With
End Sub
  • VB.NET ( NET Assembly ). Go back to the Form1_Load event and add the red code as shown here:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With Exg2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .get_Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth
            End With
            .get_Level(1).Label = "<%d%>"
        End With
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
    End With
End Sub
  • C# ( ActiveX version ). Go back to the Form1_Load event and add the red code as follows:
private void Form1_Load(object sender, EventArgs e)
{
    axG2antt1.Chart.FirstVisibleDate = new DateTime(2008,1,1);
    axG2antt1.Chart.LevelCount = 2;
    EXG2ANTTLib.Level l = axG2antt1.Chart.get_Level(0);
        l.Label = "<b><%mmmm%></b> <%yyyy%>";
        l.Unit = EXG2ANTTLib.UnitEnum.exMonth;
    axG2antt1.Chart.get_Level(1).Label = "<%d%>";
    axG2antt1.Columns.Add("Tasks");
    axG2antt1.Items.AddItem("Task 1");
    axG2antt1.Items.AddItem("Task 2");
}
  • C# ( NET Assembly ). Go back to the Form1_Load event and add the red code as shown bellow:
private void Form1_Load(object sender, EventArgs e)
{
    exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1);
    exg2antt1.Chart.LevelCount = 2;
    exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0);
    l.Label = "<b><%mmmm%></b> <%yyyy%>";
    l.Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth;
    exg2antt1.Chart.get_Level(1).Label = "<%d%>";
    exg2antt1.Columns.Add("Tasks");
    exg2antt1.Items.AddItem("Task 1");
    exg2antt1.Items.AddItem("Task 2");
}
  • C++ (6.0). Go back to the OnInitDialog method and appends the red code as shown bellow:
CChart chart = m_g2antt.GetChart();
	chart.SetFirstVisibleDate( COleVariant( COleDateTime(2008,1,1,0,0,0 ).operator DATE()));
	chart.SetLevelCount( 2 );
	CLevel level0 = chart.GetLevel(0);
	level0.SetLabel( COleVariant( "<b><%mmmm%></b> <%yyyy%>" ) );
	level0.SetUnit( 16 /*exMonth*/ );
	chart.GetLevel(1).SetLabel( COleVariant( "<%d%>" ) );
m_g2antt.GetColumns().Add("Tasks");
m_g2antt.GetItems().AddItem( COleVariant( "Task 1" ) );
m_g2antt.GetItems().AddItem( COleVariant( "Task 2" ) );
  • C++ (2005,2008). Go back to the OnInitDialog method and appends the red code as shown bellow:
EXG2ANTTLib::IChartPtr spChart = m_g2antt.get_Chart();
spChart->FirstVisibleDate = COleDateTime( 2008, 1, 1, 0, 0, 0 ).operator DATE();
spChart->LevelCount = 2;
EXG2ANTTLib::ILevelPtr spLevel0 = spChart->Level[0];
	spLevel0->Label = _T("<b><%mmmm%></b> <%yyyy%>");
	spLevel0->Unit = EXG2ANTTLib::exMonth;
spChart->Level[1]->Label = _T("<%d%>");
EXG2ANTTLib::IColumnsPtr spColumns = m_g2antt.get_Columns();
spColumns->Add(_T("Tasks"));
EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
spItems->AddItem( _T("Task 1") );
spItems->AddItem( _T("Task 2") );
  • C++ Builder (2009). Go back to the FormCreate method and appends the red code as shown bellow:
    IChartPtr spChart = G2antt1->Chart;
    spChart->set_FirstVisibleDate( TVariant(TDateTime(2008,1,1).operator double()) );
    spChart->LevelCount = 2;
    ILevelPtr spLevel0 = spChart->get_Level(0);
    	spLevel0->set_Label( TVariant(_T("<b><%mmmm%></b> <%yyyy%>")) );
    	spLevel0->set_Unit( UnitEnum::exMonth );
    spChart->get_Level(1)->set_Label( TVariant(_T("<%d%>") ) );
    IColumnsPtr spColumns = G2antt1->Columns;
    spColumns->Add( L"Tasks", TNoParam() );
    IItemsPtr spItems = G2antt1->Items;
    spItems->AddItem( TVariant("Task 1") );
    spItems->AddItem( TVariant("Task 2") );
  • Delphi (2009). Go back to the FormCreate event and add the red section:
    with G2antt1 do
    begin
     with Chart do
     begin
      FirstVisibleDate := '1/1/2008';
      LevelCount := 2;
      with Level[0] do
      begin
        Label_ := '<b><%mmmm%></b> <%yyyy%>';
        Unit_ := exMonth;
      end;
      Level[1].Label_ := '<%d%>';
     end;
     Columns.Add('Tasks');
     with Items do
     begin
       AddItem('Task 1');
       AddItem('Task 2');
     end;
    end;
  • Clarion. Go back to your embed and add the red section:
    ?Gantt{mc:Chart&'.FirstVisibleDate'} = FORMAT(TODAY()-3, @D17)
    ?Gantt{mc:Chart&'.LevelCount'} = 2
    ?Gantt{mc:Chart&'.Level(0).Label'} = '<b><%mmmm%></b> <%yyyy%>'
    ?Gantt{mc:Chart&'.Level(0).Unit'} = 64
    ?Gantt{mc:Chart&'.Level(1).Label'} = '<%d%>'
    lc:Columns = ?Gantt{'Colums'}
    lc:Items   = ?Gantt{'Items'}
    ?Gantt{lc:Columns&'.Add("Task")'}
    ?Gantt{lc:Items&'.AddItem("Task 1")'}
    ?Gantt{lc:Items&'.AddItem("Task 2")'}

Once you save the project and run again the form, you will get a screen as follows:

and previous

Finally,  let's have some code to add some bars and a link inside. The green code shows the changes required to add bars to the chart area.

  • Access. Go to the Form_Load event and replace the green section
Private Sub Form_Load()
    Dim g As EXG2ANTTLib.G2antt
    Set g = G2antt1.Object
    With g
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
        End With
        .Columns.Add ("Tasks")
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
    End With
End Sub
  • VB6. Go to the Form_Load event and replace the green section
Private Sub Form_Load()
    With G2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
        End With
        .Columns.Add ("Tasks")
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
    End With
End Sub
  • VFP. Go to the the Form1_Init method and replace the green code as follow:
with thisform.G2antt1
	With .Chart
		.FirstVisibleDate = {^2008-1-1}
		.LevelCount = 2
		With .Level(0)
			.Label = "<b><%mmmm%></b> <%yyyy%>"
			.Unit = 16
		EndWith
		.Level(1).Label = "<%d%>"
	EndWith
	.Columns.Add("Default")
	local h1,h2
	with .Items
		h1 = .AddItem("Task 1")
		.AddBar(h1,"Task",{^2008-1-2},{^2008-1-5})
		h2 = .AddItem("Task 2")
		.AddBar(h2,"Task",{^2008-1-4},{^2008-1-8})
		.AddLink("LKey",h1,"",h2,"")
	endwith
endwith
  • VB.NET ( ActiveX version ). Go back to the Form1_Load event and replace the green code as shown bellow:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With AxG2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = EXG2ANTTLib.UnitEnum.exMonth
            End With
            .Level(1).Label = "<%d%>"
        End With
        .Columns.Add("Tasks")
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
    End With
End Sub
  • VB.NET ( NET Assembly ). Go back to the Form1_Load event and add the green code as shown here:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With Exg2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .get_Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth
            End With
            .get_Level(1).Label = "<%d%>"
        End With
        .Columns.Add("Tasks")
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
    End With
End Sub
  • C# ( ActiveX version ). Go back to the Form1_Load event and replace the green code as follows:
private void Form1_Load(object sender, EventArgs e)
{
    axG2antt1.Chart.FirstVisibleDate = new DateTime(2008,1,1);
    axG2antt1.Chart.LevelCount = 2;
    EXG2ANTTLib.Level l = axG2antt1.Chart.get_Level(0);
        l.Label = "<b><%mmmm%></b> <%yyyy%>";
        l.Unit = EXG2ANTTLib.UnitEnum.exMonth;
    axG2antt1.Chart.get_Level(1).Label = "<%d%>";
    axG2antt1.Columns.Add("Tasks");
    int h1 = axG2antt1.Items.AddItem("Task 1");
    axG2antt1.Items.AddBar(h1, "Task", new DateTime(2008,1,2), new DateTime(2008,1,5),null,null);
    int h2 = axG2antt1.Items.AddItem("Task 2");
    axG2antt1.Items.AddBar(h2, "Task", new DateTime(2008,1,4), new DateTime(2008,1,8),null,null);
    axG2antt1.Items.AddLink("LKey", h1, null, h2, null);
}
  • C# ( NET Assembly ). Go back to the Form1_Load event and replace the green code as shown bellow:
private void Form1_Load(object sender, EventArgs e)
{
    exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1);
    exg2antt1.Chart.LevelCount = 2;
    exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0);
    l.Label = "<b><%mmmm%></b> <%yyyy%>";
    l.Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth;
    exg2antt1.Chart.get_Level(1).Label = "<%d%>";
    exg2antt1.Columns.Add("Tasks");
    int h1 = exg2antt1.Items.AddItem("Task 1");
    exg2antt1.Items.AddBar(h1, "Task", new DateTime(2008, 1, 2), new DateTime(2008,1,5));
    int h2 = exg2antt1.Items.AddItem("Task 2");
    exg2antt1.Items.AddBar(h2, "Task", new DateTime(2008, 1, 4), new DateTime(2008,1,8));
    exg2antt1.Items.AddLink("LKey", h1, null, h2, null);
}
  • C++ (6.0). Go back to the OnInitDialog method and replace the green code as follows:
CChart chart = m_g2antt.GetChart();
	chart.SetFirstVisibleDate( COleVariant( COleDateTime( 2008,1,1,0,0,0 ).operator DATE()));
	chart.SetLevelCount( 2 );
	CLevel level0 = chart.GetLevel(0);
	level0.SetLabel( COleVariant( "<b><%mmmm%></b> <%yyyy%>" ) );
	level0.SetUnit( 16 /*exMonth*/ );
	chart.GetLevel(1).SetLabel( COleVariant( "<%d%>" ) );
m_g2antt.GetColumns().Add("Tasks");
CItems items = m_g2antt.GetItems();
int h1 = items.AddItem( COleVariant( "Task 1" ) );
items.AddBar( h1, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008,1,2,0,0,0).operator DATE()), 
		COleVariant( COleDateTime( 2008,1,5,0,0,0).operator DATE()), 
		COleVariant(""), COleVariant() );
int h2 = items.AddItem( COleVariant( "Task 2" ) );
items.AddBar( h2, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008,1,4,0,0,0).operator DATE()), 
		COleVariant( COleDateTime( 2008,1,8,0,0,0).operator DATE()), 
		COleVariant(""), COleVariant() );
items.AddLink( COleVariant( "LKey" ), h1, COleVariant(""), h2, COleVariant("") );
  • C++ (2005,2008). Go back to the OnInitDialog method and replace the green code as follows:
EXG2ANTTLib::IChartPtr spChart = m_g2antt.get_Chart();
spChart->FirstVisibleDate = COleDateTime( 2008, 1, 1, 0, 0, 0 ).operator DATE();
spChart->LevelCount = 2;
EXG2ANTTLib::ILevelPtr spLevel0 = spChart->Level[0];
	spLevel0->Label = _T("<b><%mmmm%></b> <%yyyy%>");
	spLevel0->Unit = EXG2ANTTLib::exMonth;
spChart->Level[1]->Label = _T("<%d%>");
EXG2ANTTLib::IColumnsPtr spColumns = m_g2antt.get_Columns();
spColumns->Add(_T("Tasks"));
EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
int h1 = spItems->AddItem( _T("Task 1") );
spItems->AddBar( h1, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 2, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 5, 0, 0, 0 ).operator DATE() ),
		"" );
int h2 = spItems->AddItem( _T("Task 2") );
spItems->AddBar( h2, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 4, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 8, 0, 0, 0 ).operator DATE() ),
		"" );
spItems->AddLink( "LKey", h1, "", h2, "" );
  • C++ Builder (2009). Go back to the FormCreate method and replace the green section as follow:
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
    IChartPtr spChart = G2antt1->Chart;
    spChart->set_FirstVisibleDate( TVariant(TDateTime(2008,1,1).operator double()) );
    spChart->LevelCount = 2;
    ILevelPtr spLevel0 = spChart->get_Level(0);
    	spLevel0->set_Label( TVariant("<b><%mmmm%></b> <%yyyy%>") );
    	spLevel0->set_Unit( UnitEnum::exMonth );
    spChart->get_Level(1)->set_Label( TVariant("<%d%>") );
    IColumnsPtr spColumns = G2antt1->Columns;
    spColumns->Add( L"Tasks", TNoParam() );
    IItemsPtr spItems = G2antt1->Items;
    long h1 = spItems->AddItem( TVariant("Task 1") );
    spItems->AddBar( h1, TVariant("Task"),
    		TVariant(TDateTime(2008,1,2).operator double() ),
    		TVariant(TDateTime(2008,1,5).operator double() ),
    		TVariant("") );
    long h2 = spItems->AddItem( TVariant("Task 2") );
    spItems->AddBar( h2, TVariant("Task"),
    		TVariant(TDateTime(2008,1,4).operator double() ),
    		TVariant(TDateTime(2008,1,8).operator double() ),
    		TVariant("") );
    spItems->AddLink( TVariant("LKey"), h1, TVariant(""), h2, TVariant("") );
    }
  • Delphi (2009). Go back to the FormCreate event and replace the green code as follows:
    procedure TForm1.FormCreate(Sender: TObject);
    var h1: Integer;
    var h2: Integer;
    begin
    with G2antt1 do
    begin
     with Chart do
     begin
      FirstVisibleDate := '1/1/2008';
      LevelCount := 2;
      with Level[0] do
      begin
        Label_ := '<b><%mmmm%></b> <%yyyy%>';
        Unit_ := exMonth;
      end;
      Level[1].Label_ := '<%d%>';
     end;
     Columns.Add('Tasks');
     with Items do
     begin
      h1 := AddItem('Task 1');
      .AddBar( h1, 'Task', '1/2/2008', '1/5/2008', '', '');
      h2 := AddItem('Task 2');
       AddBar( h2, 'Task', '1/4/2008', '1/8/2008', '', '');
       AddLink('LKey', h1, '', h2, '' );
     end;
    end;
    end;
  • Clarion. Go back to your embed and add the green section:
    ?Gantt{mc:Chart&'.FirstVisibleDate'} = FORMAT(TODAY()-3, @D17)
    ?Gantt{mc:Chart&'.LevelCount'} = 2
    ?Gantt{mc:Chart&'.Level(0).Label'} = '<b><%mmmm%></b> <%yyyy%>'
    ?Gantt{mc:Chart&'.Level(0).Unit'} = 64
    ?Gantt{mc:Chart&'.Level(1).Label'} = '<%d%>'
    lc:Columns = ?Gantt{'Colums'}
    lc:Items   = ?Gantt{'Items'}
    ?Gantt{lc:Columns&'.Add("Task")'}
    h1 = ?Gantt{lc:Items&'.AddItem("Task 1")'}
    ?Gantt{mc:Items&'.AddBar('&h1&', "Task", '1/2/2008, '1/5/2008,"","")'}
    h2 = ?Gantt{lc:Items&'.AddItem("Task 2")'}
    ?Gantt{mc:Items&'.AddBar('&h2&', "Task", '1/4/2008, '1/8/2008,"","")'} 
    ?Gantt{mc:Items&'.AddLink(LKey, '&h1&', '&h2&',"")'}  

Save the project and run again the form, you will get a screen as follows:

and previous

Now, let's add a checkbox for each item, and having the bars being displayed in the histogram, also the code displays the control's overview map ( the changes are reflected in maroon )

  • Access. Go to the Form_Load event and replace the maroon section
Private Sub Form_Load()
    Dim g As EXG2ANTTLib.G2antt
    Set g = G2antt1.Object
    With g
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exPatternDot
        End With
        .Columns.Add("Tasks").Def(exCellHasCheckBox) = True
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
    End With
End Sub
  • VB6. Go to the Form_Load event and replace the maroon section
Private Sub Form_Load()
    With G2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exPatternDot
        End With
        .Columns.Add("Tasks").Def(exCellHasCheckBox) = True
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
    End With
End Sub
  • VFP. Go to the the Form1_Init method and replace the maroon code as follow:
with thisform.G2antt1
	With .Chart
		.FirstVisibleDate = {^2008-1-1}
		.LevelCount = 2
		With .Level(0)
			.Label = "<b><%mmmm%></b> <%yyyy%>"
			.Unit = 16
		EndWith
		.Level(1).Label = "<%d%>"
		.OverviewVisible = .T.
		.HistogramVisible = .T.
		.HistogramView = 4
		.HistogramHeight = 32
		.Bars("Task").HistogramPattern = 2
	EndWith
	.Columns.Add("Default").Def(0) = .T.
	local h1,h2
	with .Items
		h1 = .AddItem("Task 1")
		.AddBar(h1,"Task",{^2008-1-2},{^2008-1-5})
		h2 = .AddItem("Task 2")
		.AddBar(h2,"Task",{^2008-1-4},{^2008-1-8})
		.AddLink("LKey",h1,"",h2,"")
	endwith
endwith
  • VB.NET ( ActiveX version ). Go back to the Form1_Load event and replace the maroon code as shown bellow:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With AxG2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = EXG2ANTTLib.UnitEnum.exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = EXG2ANTTLib.PatternEnum.exPatternDot
        End With
        .Columns.Add("Tasks").Def(EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox) = True
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
    End With
End Sub
  • VB.NET ( NET Assembly ). Go back to the Form1_Load event and add the maroon code as shown here:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With Exg2antt1
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .get_Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth
            End With
            .get_Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exontrol.EXG2ANTTLib.PatternEnum.exPatternDot
        End With
        .Columns.Add("Tasks").set_Def(exontrol.EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, True)
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
    End With
End Sub
  • C# ( ActiveX version ). Go back to the Form1_Load event and replace the maroon code as follows:
private void Form1_Load(object sender, EventArgs e)
{
    axG2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1);
    axG2antt1.Chart.LevelCount = 2;
    EXG2ANTTLib.Level l = axG2antt1.Chart.get_Level(0);
    l.Label = "<b><%mmmm%></b> <%yyyy%>";
    l.Unit = EXG2ANTTLib.UnitEnum.exMonth;
    axG2antt1.Chart.get_Level(1).Label = "<%d%>";
    axG2antt1.Chart.OverviewVisible = true;
    axG2antt1.Chart.HistogramVisible = true;
    axG2antt1.Chart.HistogramView = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems;
    axG2antt1.Chart.HistogramHeight = 32;
    axG2antt1.Chart.Bars["Task"].HistogramPattern = EXG2ANTTLib.PatternEnum.exPatternDot;
    (axG2antt1.Columns.Add("Tasks") as EXG2ANTTLib.Column)
        .set_Def(EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, true);
    int h1 = axG2antt1.Items.AddItem("Task 1");
    axG2antt1.Items.AddBar(h1, "Task", new DateTime(2008, 1, 2), new DateTime(2008, 1, 5), null, null);
    int h2 = axG2antt1.Items.AddItem("Task 2");
    axG2antt1.Items.AddBar(h2, "Task", new DateTime(2008, 1, 4), new DateTime(2008, 1, 8), null, null);
    axG2antt1.Items.AddLink("LKey", h1, null, h2, null);
}
  • C# ( NET Assembly ). Go back to the Form1_Load event and replace the maroon code as shown bellow:
private void Form1_Load(object sender, EventArgs e)
{
    exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1);
    exg2antt1.Chart.LevelCount = 2;
    exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0);
    l.Label = "<b><%mmmm%></b> <%yyyy%>";
    l.Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth;
    exg2antt1.Chart.get_Level(1).Label = "<%d%>";
    exg2antt1.Chart.OverviewVisible = true;
    exg2antt1.Chart.HistogramVisible = true;
    exg2antt1.Chart.HistogramView = exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems;
    exg2antt1.Chart.HistogramHeight = 32;
    exg2antt1.Chart.Bars["Task"].HistogramPattern = exontrol.EXG2ANTTLib.PatternEnum.exPatternDot;
    exg2antt1.Columns.Add("Tasks").set_Def(exontrol.EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, true );
    int h1 = exg2antt1.Items.AddItem("Task 1");
    exg2antt1.Items.AddBar(h1, "Task", new DateTime(2008, 1, 2), new DateTime(2008, 1, 5));
    int h2 = exg2antt1.Items.AddItem("Task 2");
    exg2antt1.Items.AddBar(h2, "Task", new DateTime(2008, 1, 4), new DateTime(2008, 1, 8));
    exg2antt1.Items.AddLink("LKey", h1, null, h2, null);
}
  • C++ (6.0). Go Back to the OnInitDialog function, and replace the maroon code as follows:
CChart chart = m_g2antt.GetChart();
	chart.SetFirstVisibleDate( COleVariant( COleDateTime(2008,1,1,0,0,0).operator DATE() ) );
	chart.SetLevelCount( 2 );
	CLevel level0 = chart.GetLevel(0);
	level0.SetLabel( COleVariant( "<b><%mmmm%></b> <%yyyy%>" ) );
	level0.SetUnit( 16 /*exMonth*/ );
	chart.GetLevel(1).SetLabel( COleVariant( "<%d%>" ) );
	chart.SetOverviewVisible( TRUE );
	chart.SetHistogramVisible( TRUE );
	chart.SetHistogramView( 4 /*exHistogramCheckedItems*/ );
	chart.SetHistogramHeight( 32 );
	chart.GetBars().GetItem(COleVariant(_T("Task"))).SetHistogramPattern(2/*exPatternDot*/);
CColumn column = V_DISPATCH( &m_g2antt.GetColumns().Add("Tasks") );
column.SetDef( 0, COleVariant( VARIANT_TRUE ) );
CItems items = m_g2antt.GetItems();
int h1 = items.AddItem( COleVariant( "Task 1" ) );
items.AddBar( h1, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008, 1, 2, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 5, 0, 0, 0 ).operator DATE() ), 
		COleVariant(""), COleVariant() );
int h2 = items.AddItem( COleVariant( "Task 2" ) );
items.AddBar( h2, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008, 1, 4, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 8, 0, 0, 0 ).operator DATE() ), 
		COleVariant(""), COleVariant() );
items.AddLink( COleVariant( "LKey" ), h1, COleVariant(""), h2, COleVariant("") );
  • C++ (2005,2008). Go Back to the OnInitDialog function, and replace the maroon code as follows:
EXG2ANTTLib::IChartPtr spChart = m_g2antt.get_Chart();
spChart->FirstVisibleDate = COleDateTime( 2008, 1, 1, 0, 0, 0 ).operator DATE();
spChart->LevelCount = 2;
EXG2ANTTLib::ILevelPtr spLevel0 = spChart->Level[0];
	spLevel0->Label = _T("<b><%mmmm%></b> <%yyyy%>");
	spLevel0->Unit = EXG2ANTTLib::exMonth;
spChart->Level[1]->Label = _T("<%d%>");
spChart->OverviewVisible = VARIANT_TRUE;
spChart->HistogramVisible = VARIANT_TRUE;
spChart->HistogramView = EXG2ANTTLib::exHistogramCheckedItems;
spChart->HistogramHeight = 32;
spChart->Bars->GetItem("Task")->HistogramPattern = EXG2ANTTLib::exPatternDot;
EXG2ANTTLib::IColumnsPtr spColumns = m_g2antt.get_Columns();
EXG2ANTTLib::IColumnPtr spColumn = V_DISPATCH( &spColumns->Add(_T("Tasks")) );
spColumn->put_Def( EXG2ANTTLib::exCellHasCheckBox, CComVariant( VARIANT_TRUE ) );
EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
int h1 = spItems->AddItem( _T("Task 1") );
spItems->AddBar( h1, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 2, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 5, 0, 0, 0 ).operator DATE() ),
		"" );
int h2 = spItems->AddItem( _T("Task 2") );
spItems->AddBar( h2, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 4, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 8, 0, 0, 0 ).operator DATE() ),
		"" );
spItems->AddLink( "LKey", h1, "", h2, "" );
  • C++ Builder (2009). Go Back to the FormCreate function, and replace the maroon code as follows:
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
    	IChartPtr spChart = G2antt1->Chart;
    	spChart->set_FirstVisibleDate( TVariant(TDateTime(2008,1,1).operator double()) );
    	spChart->LevelCount = 2;
    	ILevelPtr spLevel0 = spChart->get_Level(0);
    		spLevel0->set_Label( TVariant("<b><%mmmm%></b> <%yyyy%>") );
    		spLevel0->set_Unit( UnitEnum::exMonth );
    	spChart->get_Level(1)->set_Label( TVariant("<%d%>") );
    	spChart->set_OverviewVisible( true );
    	spChart->set_HistogramVisible( true );
    	spChart->set_HistogramView( HistogramViewEnum::exHistogramCheckedItems );
    	spChart->set_HistogramHeight(32);
    	spChart->Bars->get_Item(TVariant("Task"))->set_HistogramPattern(PatternEnum::exPatternDot);
    	IColumnsPtr spColumns = G2antt1->Columns;
    	TVariant vtCol;
    	spColumns->Add( L"Tasks", &vtCol );
    	IColumnPtr spCol = vtCol;
    	spCol->set_Def( DefColumnEnum::exCellHasCheckBox, TVariant(true) );
    	IItemsPtr spItems = G2antt1->Items;
    	long h1 = spItems->AddItem( TVariant("Task 1") );
    	spItems->AddBar( h1, TVariant("Task"),
    			TVariant(TDateTime(2008,1,2).operator double() ),
    			TVariant(TDateTime(2008,1,5).operator double() ),
    			TVariant("") );
    	long h2 = spItems->AddItem( TVariant("Task 2") );
    	spItems->AddBar( h2, TVariant("Task"),
    			TVariant(TDateTime(2008,1,4).operator double() ),
    			TVariant(TDateTime(2008,1,8).operator double() ),
    			TVariant("") );
    	spItems->AddLink( TVariant("LKey"), h1, TVariant(""), h2, TVariant("") );
    }
  • Delphi (2009). Go Back to the FormCreate function, and replace the maroon code as follows:
    procedure TForm1.FormCreate(Sender: TObject);
    var h1: Integer;
    var h2: Integer;
    begin
    with G2antt1 do
    begin
     with Chart do
     begin
      FirstVisibleDate := '1/1/2008';
      LevelCount := 2;
      with Level[0] do
      begin
        Label_ := '<b><%mmmm%></b> <%yyyy%>';
        Unit_ := exMonth;
      end;
      Level[1].Label_ := '<%d%>';
      OverviewVisible := True;
      HistogramVisible := True;
      HistogramHeight := 32;
      HistogramView := exHistogramCheckedItems;
      Bars.Item['Task'].HistogramPattern := exPatternDot;
     end;
     Columns.Add('Tasks').Def[exCellHasCheckBox] := True;
     with Items do
     begin
      h1 := AddItem('Task 1');
      .AddBar( h1, 'Task', '1/2/2008', '1/5/2008', '', '');
      h2 := AddItem('Task 2');
       AddBar( h2, 'Task', '1/4/2008', '1/8/2008', '', '');
       AddLink('LKey', h1, '', h2, '' );
     end;
    end;
    end;
  • Clarion. Go back to your embed and add this code:
    ?Gantt{mc:Chart&'.FirstVisibleDate'} = FORMAT(TODAY()-3, @D17)
    ?Gantt{mc:Chart&'.LevelCount'} = 2
    ?Gantt{mc:Chart&'.Level(0).Label'} = '<b><%mmmm%></b> <%yyyy%>'
    ?Gantt{mc:Chart&'.Level(0).Unit'} = 64
    ?Gantt{mc:Chart&'.Level(1).Label'} = '<%d%>'
    ?Gantt{mc.Chart&'.OverviewVisible'} = True
    ?Gantt{mc.Chart&'.HistogramVisible'} = True
    ?Gantt{mc.Chart&'.HistogramView'} = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
    ?Gantt{mc.Chart&'.HistogramHeight'} = 32
    ?Gantt{mc.Chart&'.Bars("Task").HistogramPattern'} = EXG2ANTTLib.PatternEnum.exPatternDot
    lc:Columns = ?Gantt{'Colums'}
    lc:Items   = ?Gantt{'Items'}
    ?Gantt{lc:Columns&'.Add("Task").Def(exCellHasCheckBox)'} = True
    h1 = ?Gantt{lc:Items&'.AddItem("Task 1")'}
    ?Gantt{mc:Items&'.AddBar('&h1&', "Task", '1/2/2008, '1/5/2008,"","")'}
    h2 = ?Gantt{lc:Items&'.AddItem("Task 2")'}
    ?Gantt{mc:Items&'.AddBar('&h2&', "Task", '1/4/2008, '1/8/2008,"","")'} 
    ?Gantt{mc:Items&'.AddLink(LKey, '&h1&', '&h2&',"")'}  

Save the project and run the form again. Click the checkbox for each item and you should get the following screen shot:

and previous

Finally let's optimize the calling the BeginUpdate/EndUpdate methods, for performance, and grouping calling the same property several times as seen in the C# for Items or Chart property.

  • Access
Private Sub Form_Load()
    Dim g As EXG2ANTTLib.G2antt
    Set g = G2antt1.Object
    With g
        .BeginUpdate
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exPatternDot
        End With
        .Columns.Add("Tasks").Def(exCellHasCheckBox) = True
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
        .EndUpdate
    End With
End Sub
  • VB6
Private Sub Form_Load()
    With G2antt1
        .BeginUpdate
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exPatternDot
        End With
        .Columns.Add("Tasks").Def(exCellHasCheckBox) = True
        Dim h1, h2 As Long
        With .Items
            h1 = .AddItem("Task 1")
            .AddBar h1, "Task", #1/2/2008#, #1/5/2008#
            h2 = .AddItem("Task 2")
            .AddBar h2, "Task", #1/4/2008#, #1/8/2008#
            .AddLink "LKey", h1, "", h2, ""
        End With
        .EndUpdate
    End With
End Sub
  • VFP
with thisform.G2antt1
	.BeginUpdate
	With .Chart
		.FirstVisibleDate = {^2008-1-1}
		.LevelCount = 2
		With .Level(0)
			.Label = "<b><%mmmm%></b> <%yyyy%>"
			.Unit = 16
		EndWith
		.Level(1).Label = "<%d%>"
        .OverviewVisible = .T.
        .HistogramVisible = .T.
        .HistogramView = 4
        .HistogramHeight = 32
        .Bars("Task").HistogramPattern = 2
    EndWith
	.Columns.Add("Default").Def(0) = .T.
	local h1,h2
	with .Items
		h1 = .AddItem("Task 1")
		.AddBar(h1,"Task",{^2008-1-2},{^2008-1-5})
		h2 = .AddItem("Task 2")
		.AddBar(h2,"Task",{^2008-1-4},{^2008-1-8})
		.AddLink("LKey",h1,"",h2,"")
	endwith
	.EndUpdate
endwith
  • VB.NET ( ActiveX version ).  
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With AxG2antt1
        .BeginUpdate()
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = EXG2ANTTLib.UnitEnum.exMonth
            End With
            .Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = EXG2ANTTLib.PatternEnum.exPatternDot
        End With
        .Columns.Add("Tasks").Def(EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox) = True
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
        .EndUpdate()
    End With
End Sub
  • VB.NET ( NET Assembly ). 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With Exg2antt1
        .BeginUpdate()
        With .Chart
            .FirstVisibleDate = #1/1/2008#
            .LevelCount = 2
            With .get_Level(0)
                .Label = "<b><%mmmm%></b> <%yyyy%>"
                .Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth
            End With
            .get_Level(1).Label = "<%d%>"
            .OverviewVisible = True
            .HistogramVisible = True
            .HistogramView = exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
            .HistogramHeight = 32
            .Bars("Task").HistogramPattern = exontrol.EXG2ANTTLib.PatternEnum.exPatternDot
        End With
        .Columns.Add("Tasks").set_Def(exontrol.EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, True)
        With .Items
            Dim h1 As Integer = .AddItem("Task 1")
            .AddBar(h1, "Task", #1/2/2008#, #1/5/2008#)
            Dim h2 As Integer = .AddItem("Task 2")
            .AddBar(h2, "Task", #1/4/2008#, #1/8/2008#)
            .AddLink("LKey", h1, "", h2, "")
        End With
        .EndUpdate()
    End With
End Sub
  • C# ( ActiveX version ).
private void Form1_Load(object sender, EventArgs e)
{
    axG2antt1.BeginUpdate();
    EXG2ANTTLib.Chart chart = axG2antt1.Chart;
    chart.FirstVisibleDate = new DateTime(2008, 1, 1);
    chart.LevelCount = 2;
    EXG2ANTTLib.Level l = chart.get_Level(0);
    l.Label = "<b><%mmmm%></b> <%yyyy%>";
    l.Unit = EXG2ANTTLib.UnitEnum.exMonth;
    chart.get_Level(1).Label = "<%d%>";
    chart.OverviewVisible = true;
    chart.HistogramVisible = true;
    chart.HistogramView = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems;
    chart.HistogramHeight = 32;
    chart.Bars["Task"].HistogramPattern = EXG2ANTTLib.PatternEnum.exPatternDot;
    (axG2antt1.Columns.Add("Tasks") as EXG2ANTTLib.Column)
        .set_Def(EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, true);
    EXG2ANTTLib.Items items = axG2antt1.Items;
    int h1 = items.AddItem("Task 1");
    items.AddBar(h1, "Task", new DateTime(2008, 1, 2), new DateTime(2008, 1, 5), null, null);
    int h2 = items.AddItem("Task 2");
    items.AddBar(h2, "Task", new DateTime(2008, 1, 4), new DateTime(2008, 1, 8), null, null);
    items.AddLink("LKey", h1, null, h2, null);
    axG2antt1.EndUpdate();
}
  • C# ( NET Assembly ). Go back to the Form1_Load event and replace the maroon code as shown bellow:
private void Form1_Load(object sender, EventArgs e)
{
    exg2antt1.BeginUpdate();
    exontrol.EXG2ANTTLib.Chart chart = exg2antt1.Chart;
        chart.FirstVisibleDate = new DateTime(2008, 1, 1);
        chart.LevelCount = 2;
        exontrol.EXG2ANTTLib.Level l = chart.get_Level(0);
        l.Label = "<b><%mmmm%></b> <%yyyy%>";
        l.Unit = exontrol.EXG2ANTTLib.UnitEnum.exMonth;
        chart.get_Level(1).Label = "<%d%>";
        chart.OverviewVisible = true;
        chart.HistogramVisible = true;
        chart.HistogramView = exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems;
        chart.HistogramHeight = 32;
        chart.Bars["Task"].HistogramPattern = exontrol.EXG2ANTTLib.PatternEnum.exPatternDot;
    exg2antt1.Columns.Add("Tasks").set_Def(exontrol.EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, true );
    exontrol.EXG2ANTTLib.Items items = exg2antt1.Items;
    int h1 = items.AddItem("Task 1");
    items.AddBar(h1, "Task", new DateTime(2008, 1, 2), new DateTime(2008, 1, 5));
    int h2 = exg2antt1.Items.AddItem("Task 2");
    items.AddBar(h2, "Task", new DateTime(2008, 1, 4), new DateTime(2008, 1, 8));
    items.AddLink("LKey", h1, null, h2, null);
    exg2antt1.EndUpdate();
}
  • C++ (6.0). Go back to the OnInitDialog and replace the maroon code as shown bellow:
m_g2antt.BeginUpdate();
CChart chart = m_g2antt.GetChart();
	chart.SetFirstVisibleDate( COleVariant( COleDateTime( 2008, 1, 1, 0, 0, 0 ).operator DATE() ) );
	chart.SetLevelCount( 2 );
	CLevel level0 = chart.GetLevel(0);
	level0.SetLabel( COleVariant( "<b><%mmmm%></b> <%yyyy%>" ) );
	level0.SetUnit( 16 /*exMonth*/ );
	chart.GetLevel(1).SetLabel( COleVariant( "<%d%>" ) );
	chart.SetOverviewVisible( TRUE );
	chart.SetHistogramVisible( TRUE );
	chart.SetHistogramView( 4 /*exHistogramCheckedItems*/ );
	chart.SetHistogramHeight( 32 );
	chart.GetBars().GetItem( COleVariant( _T("Task") ) ).SetHistogramPattern( 2/*exPatternDot*/ );
CColumn column = V_DISPATCH( &m_g2antt.GetColumns().Add("Tasks") );
column.SetDef( 0, COleVariant( VARIANT_TRUE ) );
CItems items = m_g2antt.GetItems();
int h1 = items.AddItem( COleVariant( "Task 1" ) );
items.AddBar( h1, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008, 1, 2, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 5, 0, 0, 0 ).operator DATE() ), 
		COleVariant(""), COleVariant() );
int h2 = items.AddItem( COleVariant( "Task 2" ) );
items.AddBar( h2, COleVariant( "Task" ), 
		COleVariant( COleDateTime( 2008, 1, 4, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 8, 0, 0, 0 ).operator DATE() ), 
		COleVariant(""), COleVariant() );
items.AddLink( COleVariant( "LKey" ), h1, COleVariant(""), h2, COleVariant("") );
m_g2antt.EndUpdate();
  • C++ (2005,2008). Go back to the OnInitDialog and replace the maroon code as shown bellow:
m_g2antt.BeginUpdate();
EXG2ANTTLib::IChartPtr spChart = m_g2antt.get_Chart();
spChart->FirstVisibleDate = COleDateTime( 2008, 1, 1, 0, 0, 0 ).operator DATE();
spChart->LevelCount = 2;
EXG2ANTTLib::ILevelPtr spLevel0 = spChart->Level[0];
	spLevel0->Label = _T("<b><%mmmm%></b> <%yyyy%>");
	spLevel0->Unit = EXG2ANTTLib::exMonth;
spChart->Level[1]->Label = _T("<%d%>");
spChart->OverviewVisible = VARIANT_TRUE;
spChart->HistogramVisible = VARIANT_TRUE;
spChart->HistogramView = EXG2ANTTLib::exHistogramCheckedItems;
spChart->HistogramHeight = 32;
spChart->Bars->GetItem("Task")->HistogramPattern = EXG2ANTTLib::exPatternDot;
EXG2ANTTLib::IColumnsPtr spColumns = m_g2antt.get_Columns();
EXG2ANTTLib::IColumnPtr spColumn = V_DISPATCH( &spColumns->Add(_T("Tasks")) );
spColumn->put_Def( EXG2ANTTLib::exCellHasCheckBox, CComVariant( VARIANT_TRUE ) );
EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
int h1 = spItems->AddItem( _T("Task 1") );
spItems->AddBar( h1, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 2, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 5, 0, 0, 0 ).operator DATE() ),
		"" );
int h2 = spItems->AddItem( _T("Task 2") );
spItems->AddBar( h2, _T("Task"), 
		COleVariant( COleDateTime( 2008, 1, 4, 0, 0, 0 ).operator DATE() ), 
		COleVariant( COleDateTime( 2008, 1, 8, 0, 0, 0 ).operator DATE() ),
		"" );
spItems->AddLink( "LKey", h1, "", h2, "" );
m_g2antt.EndUpdate();
  • C++ Builder (2009). Go back to the FormCreate and add marron section as follow:
void __fastcall TForm1::FormCreate(TObject *Sender)
{
	G2antt1->BeginUpdate();
	IChartPtr spChart = G2antt1->Chart;
	spChart->set_FirstVisibleDate( TVariant(TDateTime(2008,1,1).operator double()) );
	spChart->LevelCount = 2;
	ILevelPtr spLevel0 = spChart->get_Level(0);
		spLevel0->set_Label( TVariant("<b><%mmmm%></b> <%yyyy%>") );
		spLevel0->set_Unit( UnitEnum::exMonth );
	spChart->get_Level(1)->set_Label( TVariant("<%d%>") );
	spChart->set_OverviewVisible( true );
	spChart->set_HistogramVisible( true );
	spChart->set_HistogramView( HistogramViewEnum::exHistogramCheckedItems );
	spChart->set_HistogramHeight(32);
	spChart->Bars->get_Item(TVariant("Task"))->set_HistogramPattern(PatternEnum::exPatternDot);
	IColumnsPtr spColumns = G2antt1->Columns;
	TVariant vtCol;
	spColumns->Add( L"Tasks", &vtCol );
	IColumnPtr spCol = vtCol;
	spCol->set_Def( DefColumnEnum::exCellHasCheckBox, TVariant(true) );
	IItemsPtr spItems = G2antt1->Items;
	long h1 = spItems->AddItem( TVariant("Task 1") );
	spItems->AddBar( h1, TVariant("Task"),
			TVariant(TDateTime(2008,1,2).operator double() ),
			TVariant(TDateTime(2008,1,5).operator double() ),
			TVariant("") );
	long h2 = spItems->AddItem( TVariant("Task 2") );
	spItems->AddBar( h2, TVariant("Task"),
			TVariant(TDateTime(2008,1,4).operator double() ),
			TVariant(TDateTime(2008,1,8).operator double() ),
			TVariant("") );
	spItems->AddLink( TVariant("LKey"), h1, TVariant(""), h2, TVariant("") );
	G2antt1->EndUpdate();
}
  • Delphi (2009). Go back to the FormCreate and add marron section as follow
procedure TForm1.FormCreate(Sender: TObject);
var h1: Integer;
var h2: Integer;
begin
with G2antt1 do
begin
 BeginUpdate;
 with Chart do
 begin
  FirstVisibleDate := '1/1/2008';
  LevelCount := 2;
  with Level[0] do
  begin
    Label_ := '<b><%mmmm%></b> <%yyyy%>';
    Unit_ := exMonth;
  end;
  Level[1].Label_ := '<%d%>';
  OverviewVisible := True;
  HistogramVisible := True;
  HistogramHeight := 32;
  HistogramView := exHistogramCheckedItems;
  Bars.Item['Task'].HistogramPattern := exPatternDot;
 end;
 Columns.Add('Tasks').Def[exCellHasCheckBox] := True;
 with Items do
 begin
  h1 := AddItem('Task 1');
  .AddBar( h1, 'Task', '1/2/2008', '1/5/2008', '', '');
  h2 := AddItem('Task 2');
   AddBar( h2, 'Task', '1/4/2008', '1/8/2008', '', '');
   AddLink('LKey', h1, '', h2, '' );
 end;
 EndUpdate;
end;
end;
  • Clarion. Go back to your embed and add this code:
    ?Gantt{'BeginUpdate'}
    ?Gantt{mc:Chart&'.FirstVisibleDate'} = FORMAT(TODAY()-3, @D17)
    ?Gantt{mc:Chart&'.LevelCount'} = 2
    ?Gantt{mc:Chart&'.Level(0).Label'} = '<b><%mmmm%></b> <%yyyy%>'
    ?Gantt{mc:Chart&'.Level(0).Unit'} = 64
    ?Gantt{mc:Chart&'.Level(1).Label'} = '<%d%>'
    ?Gantt{mc.Chart&'.OverviewVisible'} = True
    ?Gantt{mc.Chart&'.HistogramVisible'} = True
    ?Gantt{mc.Chart&'.HistogramView'} = EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems
    ?Gantt{mc.Chart&'.HistogramHeight'} = 32
    ?Gantt{mc.Chart&'.Bars("Task").HistogramPattern'} = EXG2ANTTLib.PatternEnum.exPatternDot
    lc:Columns = ?Gantt{'Colums'}
    lc:Items   = ?Gantt{'Items'}
    ?Gantt{lc:Columns&'.Add("Task").Def(exCellHasCheckBox)'} = True
    h1 = ?Gantt{lc:Items&'.AddItem("Task 1")'}
    ?Gantt{mc:Items&'.AddBar('&h1&', "Task", '1/2/2008, '1/5/2008,"","")'}
    h2 = ?Gantt{lc:Items&'.AddItem("Task 2")'}
    ?Gantt{mc:Items&'.AddBar('&h2&', "Task", '1/4/2008, '1/8/2008,"","")'} 
    ?Gantt{mc:Items&'.AddLink(LKey, '&h1&', '&h2&',"")'}
    ?Gantt{'EndUpdate'} 
The following snippets of code reference the component using its type library. Go Back.
  • Access. The name of the library is EXG2ANTTLib while the name of the main component is G2antt. The native object may be accessed through the Object property so G2antt1.Object is of  EXG2ANTTLib.G2antt type. While in CodeView mode, you can press the F2 key to open the "Object Browser" where all libraries are listed. 
Private Sub init(ByVal g As EXG2ANTTLib.G2antt)
    With g
        .BeginUpdate
        .Columns.Add ("Tasks")
        With .Items
            .AddItem "Task 1"
            .AddItem "Task 2"
        End With
        .EndUpdate
    End With
End Sub

Private Sub Form_Load()
    Call init(G2antt1.Object)
End Sub
  • VB6. The name of the library is EXG2ANTTLibCtl while the name of the main component is G2antt. The native object may be accessed throw the object itself or through the Object property so G2antt1 is of  EXG2ANTTLibCtl.G2antt type. While in CodeView mode, you can press the F2 key to open the "Object Browser" where all libraries are listed.
Private Sub init(ByVal g As EXG2ANTTLibCtl.G2antt)
    With g
        .BeginUpdate
        .Columns.Add ("Tasks")
        With .Items
            .AddItem "Task 1"
            .AddItem "Task 2"
        End With
        .EndUpdate
    End With
End Sub

Private Sub Form_Load()
    init G2antt1
End Sub
  • VFP. The name of the library is EXG2ANTTLib while the name of the main component is G2antt. The native object may be accessed through the Object property so G2antt1.Object is of  EXG2ANTTLib.G2antt type. Select Tools, Class Browser, Click Open, select the *.dll, and locate the exg2antt.dll file. The Class browser will display the component's library. 
LPARAMETER g

With g
    .BeginUpdate
    .Columns.Add ("Tasks")
    With .Items
        .AddItem("Task 1")
        .AddItem("Task 2")
    EndWith
    .EndUpdate
EndWith
thisform.initC(thisform.G2antt1)
  • VB.NET ( ActiveX version ). The name of the library is EXG2ANTTLib while the name of the main component is G2antt. The native object may be accessed through the GetOcx() method so G2antt1.GetOcx() is of  EXG2ANTTLib.G2antt type. Select the View\Class View and locate the Interop.EXG2ANTTLib assembly where you can find the component's library.
Private Sub init(ByVal g As EXG2ANTTLib.G2antt)
    With g
        .BeginUpdate()
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
        .EndUpdate()
    End With
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Call init(AxG2antt1.GetOcx())
End Sub
  • VB.NET ( NET Assembly ). The name of the library is exontrol.EXG2ANTTLib while the name of the main component is exg2antt. The native object may be accessed through the object itself so it is of  exontrol.EXG2ANTTLib.exg2antt type. Select the View\Class View and locate the exontrol.exg2antt assembly where you can find the component's library.
Private Sub init(ByVal g As exontrol.EXG2ANTTLib.exg2antt)
    With g
        .BeginUpdate()
        .Columns.Add("Tasks")
        With .Items
            .AddItem("Task 1")
            .AddItem("Task 2")
        End With
        .EndUpdate()
    End With
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Call init(Exg2antt1)
End Sub
  • C# ( ActiveX version ). The name of the library is EXG2ANTTLib while the name of the main component is G2antt. The native object may be accessed through the GetOcx() method so G2antt1.GetOcx() is of  EXG2ANTTLib.G2antt type. Select the View\Class View and locate the Interop.EXG2ANTTLib assembly where you can find the component's library.
private void init(EXG2ANTTLib.G2antt g)
{
    g.BeginUpdate();
    g.Columns.Add("Tasks");
    g.Items.AddItem("Task 1");
    g.Items.AddItem("Task 2");
    g.EndUpdate();
}
private void Form1_Load(object sender, EventArgs e)
{
    init(axG2antt1.GetOcx() as EXG2ANTTLib.G2antt);
}
  • C# ( NET Assembly ). The name of the library is exontrol.EXG2ANTTLib while the name of the main component is exg2antt. The native object may be accessed through the object itself so it is of  exontrol.EXG2ANTTLib.exg2antt type. Select the View\Class View and locate the exontrol.exg2antt assembly where you can find the component's library.
private void init(exontrol.EXG2ANTTLib.exg2antt g)
{
    g.BeginUpdate();
    g.Columns.Add("Tasks");
    g.Items.AddItem("Task 1");
    g.Items.AddItem("Task 2");
    g.EndUpdate();
}

private void Form1_Load(object sender, EventArgs e)
{
    init(exg2antt1);
}
  • C++ (6.0).  The ClassWizard generates the class CG2antt, for the component, so you may refer the component using this class. The same you can generate the wrapper classes using the #import <exg2antt.dl> as explained in the C++ ( 2005 )/
#include "Columns.h"
#include "Items.h"
void init( CG2antt& g )
{
	g.BeginUpdate();
	g.GetColumns().Add( "Tasks" );
	g.GetItems().AddItem( COleVariant("Task 1") );
	g.GetItems().AddItem( COleVariant("Task 2") );
	g.EndUpdate();
}

init(m_g2antt);
  • C++ (2005,2008). The #import <exg2antt.dll> must be called somewhere in your code, so the EXG2ANTTLib namespace is defined. 
#import <exg2antt.dll>
void init( EXG2ANTTLib::IG2antt* pG )
{
	pG->BeginUpdate();
	pG->Columns->Add( _T("Tasks") );
	pG->Items->AddItem( _T("Task 1") );
	pG->Items->AddItem( _T("Task 2") );
	pG->EndUpdate();
}

init( (EXG2ANTTLib::IG2anttPtr)GetDlgItem( IDC_G2ANTT1 )->GetControlUnknown() );
  • C++ Builder (2009).  The name of the namespace being generated is Exg2anttlib_tlb, and the init function can e defined as follows:
    void TForm2::init( Exg2anttlib_tlb::TG2antt* pG )
    {
    	pG->BeginUpdate();
    	pG->Columns->Add(L"Tasks", TNoParam() );
    	pG->Items->AddItem(TVariant("Task 1"));
    	pG->Items->AddItem(TVariant("Task 2"));
    	pG->EndUpdate();
    }
    init(G2antt1);
  • Delphi (2009). The name of the library is EXG2ANTTLib or EXG2ANTTLib_TLB, while the init procedure may be like follows:
procedure Init(G: TG2antt);
begin
 with G do
 begin
   BeginUpdate;
   Columns.Add('Tasks');
   with Items do
   begin
     AddItem('Task 1');
     AddItem('Task 2');
   end;
   EndUpdate;
 end;
end;
  • Clarion. The name of the library is Exontrol.G2antt.1, while the init procedure may be like follows
procedure Gantt.Init PROCEDURE(Window TheWindow,LONG ControlLabel,BYTE DebugMode = FALSE)
! Data
Loc:lX       LONG
Loc:lY       LONG
Loc:lWidth   LONG
Loc:lHeight  LONG
Loc:lParent  LONG
! Code
Loc:lParent = ControlLabel{PROP:Parent}
Loc:lX      = ControlLabel{PROP:XPos}
Loc:lY      = ControlLabel{PROP:YPos}
Loc:lWidth  = ControlLabel{PROP:Width}
Loc:lHeight = ControlLabel{PROP:Height}
Destroy(ControlLabel)
SELF.OleObject = Create(ControlLabel,CREATE:Ole,Loc:lParent)
IF ~SELF.OleObject then Return End
SELF.OleObject{PROP:Create} = 'Exontrol.G2antt.1'
If DebugMode = TRUE
  SELF.OleObject{PROP:ReportException} = TRUE
End
SELF.OleObject{PROP:Compatibility} = 1
SELF.OleObject{PROP:XPos}   = Loc:lX
SELF.OleObject{PROP:YPos}   = Loc:lY
SELF.OleObject{PROP:Width}  = Loc:lWidth
SELF.OleObject{PROP:Height} = Loc:lHeight
OcxRegisterEventProc(SELF.OleObject,ControlEventHandler)
SELF.OleObject{PROP:Hide} = FALSE
SELF.Initialized = TRUE
RETURN
Now, let's see how we can print the control's content. The eXPrint component provides print and print preview capabilities for our UI components.  First, we need to insert the exprint component to the form or dialog. Go Back.
  • Access. Click the More Controls icon in the Toolbox, locate and select the ExPrint ActiveX Control in the shortcut menu being opened. Click the form and drag the cursor to a new position, so the control is being inserted to your form.
  • VB6. Select the Project\Components (CTRL+T) and locate the ExPrint Control Library, check it, and click the OK button. The Print icon is shown in the Toolbox, double click it or select and put it to your form.
  • VFP. Select Tools\Options\Controls and locate the ExPrint ActiveX Control in Selected list box. Check it, and click the Set As Default, then click OK. The ExPrint icon is shown in the Form Controls toolbox, click it, so the cursor is changed, go to the for and put it ( click and drag the cursor to a new position ).
  • VB.NET ( ActiveX version ). Right click the Toolbox, select the Choose Items,  and then select the COM Components page, locate the ExPrint ActiveX Control, check it, and click ok. The toolbox includes the ExPrint ActiveX Control icon, double click it.
  • VB.NET ( NET Assembly ). Right click the Toolbox, select the Choose Items,  and then select the .NET Framework Components page, click the Browse button, so the Open file dialog is shown. Locate the exontrol.exprint.dll ( usually it goes to the C:\Program Files\Exontrol\ExPrint.NET folder ), select it, and click OK, so the .NET Framework Components list displays a new checked items called exprint. Click ok. The toolbox includes the exprint  icon, double click it.
  • C# ( ActiveX version ). Right click the Toolbox, select the Choose Items,  and then select the COM Components page, locate the ExPrint ActiveX Control, check it, and click ok. The toolbox includes the ExPrint ActiveX Control icon, double click it.
  • C# ( NET Assembly ). Right click the Toolbox, select the Choose Items,  and then select the .NET Framework Components page, click the Browse button, so the Open file dialog is shown. Locate the exontrol.exprint.dll ( usually it goes to the C:\Program Files\Exontrol\ExPrint.NET folder ), select it, and click OK, so the .NET Framework Components list displays a new checked items called exprint. Click ok. The toolbox includes the exprint icon, double click it.
  • C++ (6.0). Select the dialog where you need to insert the control. Right click, and select the  Insert ActiveX control, locate and select the ExPrint ActiveX Control and then click ok. Invoke the MFC ClassWizard ( CTRL + W ), click the Member Variables page, select the IDC_PRINT1 identifier in the Control IDs list, and click the Add Variable ... button, so a member variable is added. Confirm the classes going to be added to your project and select OK. Specify the name of the member variable being inserted as m_print for instance. Click OK, and the Close the MFC ClassWizard, by clicking again the OK button.
  • C++ (2005,2008). Select the dialog in design mode, where you need to insert the control, in the Resource \ Dialog section. Right click, and select the  Insert ActiveX control, locate and select the ExPrint ActiveX Control and then click ok. The control is automatically added to your dialog. Select the control in design mode, and then right click, and select the Add Variable shortcut menu, specify the name of the variable to be created ( Variable name field ), m_print for instance, and then click Finish button.
  • C++ Builder (2009). Select the "Component \Import Component..." and then "Import ActiveX Control" or "Import .NET Assembly", depending on what version you are about to import. If ActiveX, select the ExPrint Control Library from the list of "Registered ActiveX Controls", and then click Next. You will be informed of the "Generated import file", Check the "Generate Component Wrappers", Click Next, and select "Install To Existing Package" , Click Next, and select the package where the eXPrint should be added, and then Click Finish, The package is generated and installed. Select the Form where you want to insert the component, and then locate the TPrint in the ActiveX section of the IDE's Tool Palette. Double click it or drag it to your form, so the component will be inserted to the form.
  • Delphi (2009). Select the "Component \Import Component..." and then "Import ActiveX Control" or "Import .NET Assembly", depending on what version you are about to import. If ActiveX, select the ExPrint Control Library from the list of "Registered ActiveX Controls", and then click Next. You will be informed of the "Generated import file", Check the "Generate Component Wrappers", Click Next, and select "Install To Existing Package" , Click Next, and select the package where the eXPrint should be added, and then Click Finish, The package is generated and installed. Select the Form where you want to insert the component, and then locate the TPrint in the ActiveX section of the IDE's Tool Palette. Double click it or drag it to your form, so the component will be inserted to the form.
  • Clarion: Choose Ole control from Control template toolbar. In Object type enter: Exontrol.Print.1. Be shure that OCX is ticked, and EVENT Handler, too. Name it ?Print.

Next step required in order to print or print preview our data, is to set the PrintExt method and then call the Preview or DoPrint method as follows. 

  • Access. The Object method of the G2antt1 object gets the native or the original component. 
Private Sub callPreview()
    With Print1
        Set .PrintExt = G2antt1.Object
        .preview
    End With
End Sub
  • VB6. The Object method of the G2antt1 object gets the native or the original component. 
Private Sub callPreview()
    With Print1
        Set .PrintExt = G2antt1.Object
        .Preview
    End With
End Sub
  • VFP. The Object method of the G2antt1 object gets the native or the original component. 
with thisform.Print1
	.PrintExt = thisform.G2antt1.Object
	.Preview
endwith
  • VB.NET ( ActiveX version ). The GetOcx method of the G2antt1 object gets the native or the original component. 
Private Sub callPreview()
    With AxPrint1
        .PrintExt = AxG2antt1.GetOcx()
        .Preview()
    End With
End Sub
  • VB.NET ( NET Assembly ). 
Private Sub callPreview()
    With Exprint1
        .PrintExt = Exg2antt1
        .Preview()
    End With
End Sub
  • C# ( ActiveX version ). The GetOcx method of the G2antt1 object gets the native or the original component. 
private void callPreview()
{
    axPrint1.PrintExt = axG2antt1.GetOcx();
    axPrint1.Preview();

}
  • C# ( NET Assembly ). 
private void callPreview()
{
    exprint1.PrintExt = exg2antt1;
    exprint1.Preview();
}
  • C++ (6.0). The m_print member of the CWindowMFCDlg class, is of CExPrint type ( which has been defined by the class wizard ). The m_g2antt member is of CG2antt type that has been defined by the class wizard. The GetControlUnknown method retrieves a pointer to IUnknown interface being implemented by the original component, which is the pointer required by the PrintExt method before calling the Preview or DoPrint method of the eXPrint component.
void CWindowMFCDlg::callPreview()
{
	m_print.SetPrintExt( m_g2antt.GetControlUnknown() );
	m_print.Preview();
}
  • C++ (2005,2008). The m_print member of the CWindowMFCDlg class, is of CExPrint type ( which has been defined by the class wizard ). The m_g2antt member is of CG2antt type that has been defined by the class wizard. The GetControlUnknown method retrieves a pointer to IUnknown interface being implemented by the original component, which is the pointer required by the PrintExt method before calling the Preview or DoPrint method of the eXPrint component.
void CWindowMFCDlg::callPreview()
{
	m_print.put_PrintExt( m_g2antt.GetControlUnknown() );
	m_print.Preview();
}
  • C++ Builder (2009). The DefaultDispatch function of the TOleControl retrieves the original object, so it can be passed to PrintExt function of the eXPrint in order to print or print preview the component, as seen in the callpreview function:
void TForm1::callPreview()
{
	Print1->PrintExt = G2antt1->DefaultDispatch;
	Print1->Preview();
}
  • Delphi (2009). The DefaultDispatch function of the TOleControl retrieves the original object, so it can be passed to PrintExt function of the eXPrint in order to print or print preview the component, as seen in the callpreview function:
procedure callPreview(P : TPrint; G : TG2antt);
begin
with P do
begin
 PrintExt := G.DefaultDispatch;
 Preview();
end;
end;
callPreview( Print1, G2antt1 );
  • Clarion. Code under ?PrintThis button, with some properties:

     ?Print{'Settings(10)'} = 1
     ?Print{'PrintExt'} = ?Gantt{PROP:Object}            ! If we going to print ExGantt
     ?Print{'AsScreen'} = False                                   ! Sometimes makes problems under Terminal services
     ?Print{'PageOrientation'} = 2
     ?Print{'Caption'} = 'Some text'
     ?Print{'Settings(6)'} = 1500
     ?Print{'Settings(7)'} = 1500
     ?Print{'Settings(8)'} = 1500
     ?Print{'Settings(9)'} = 1500
     ?Print{'Font.Name'}   = 'Arial'
     ?Print{'Font.Size'}   = 9
     ?Print{'Preview'}

Call the callPreview method when you need ie clicking a button, save and run the project. Once the callPreview method is called, the 'Untitled Document' Print Preview window is opened where you can see the preview of the control's data. In our case, we should get a picture like follows:

All of our UI components ( ActiveX controls ), provides a Template feature. This allows calling properties or methods of the control using a string without compiling. For instance, a code like follows Template = "BackColor = RGB(255,0,0)" changes the control's background color to red. The Template script is composed by lines of instructions. Instructions are separated by "\n\r" ( newline ) characters. Go Back.

An instruction can be one of the following:

  • Dim list of variables Declares the variables. Multiple variables are separated by commas. ( Sample: Dim h, h1, h2 )
  • variable = property( list of arguments ) Assigns the result of the property to a variable. The "variable" is the name of a declared variable. The "property" is the property name of the object in the context. The "list or arguments" may include variables or values separated by commas.  ( Sample: h = InsertItem(0,"New Child") )
  • property( list of arguments ) = value Changes the property. The value can be a variable, a string, a number, a boolean value or a RGB value.
  • method( list of arguments ) Invokes the method. The "list or arguments" may include variables or values separated by commas.
  • { Beginning the object's context. The properties or methods called between { and } are related to the last object returned by the property prior to { declaration.
  • } Ending the object's context
  • object. property( list of arguments ).property( list of arguments ).... The .(dot) character splits the object from its property. For instance, the Columns.Add("Column1").HeaderBackColor = RGB(255,0,0), adds a new column and changes the column's header back color.

Here's the Template required to generate the same imagine as the above code will be:

BeginUpdate()
Chart
{
	FirstVisibleDate = #1/1/2008#
	LevelCount = 2
	Level(0)
	{
		Label = `<b><%mmmm%></b> <%yyyy%>`
		Unit = 16
	}
	OverviewVisible = True
	HistogramVisible = True
	HistogramView = 4
	HistogramHeight = 32
	Bars(`Task`).HistogramPattern = 2
}
Columns.Add(`Tasks`).Def(0) = True
Items
{
	Dim h1, h2
	h1 = AddItem(`Task 1`)
	AddBar(h1, `Task`, #1/2/2008#, #1/5/2008#)
	h2 = AddItem(`Task 1`)
	AddBar(h2, `Task`, #1/4/2008#, #1/8/2008#)
	AddLink(`LKey`,h1,``,h2,``)
}
EndUpdate()  

A string may be declared between " or ` as well.

The Template supports the following general functions:

  • RGB(R,G,B) property retrieves a RGB value, where the R, G, B are byte values that indicates the R G B values for the color being specified. For instance, the following code changes the control's background color to red: BackColor = RGB(255,0,0)
  • CreateObject(progID) property creates and retrieves a single uninitialized object of the class associated with a specified program identifier.
  • Me retrieves the original object
  • LoadPicture(filename) loads a picture from the filename and retrieves a picture object

Calling the Template property will not remove or erase the control's data before executing, so you can call Template property several times. For instance, you can declare a template as follow: "Items.AddItem(``)". Calling it 5 times will add actually 5 new items. The Exontrol's eXHelper tool helps you to find easy and quickly the answers and the source code for your questions regarding the usage of our UI components. The eXHelper toiol is able to translate the template script to VBA, VB6, VB.NET, VFP6, VFP9, C# and C++ .

Now, let's add an event handler for the component. For instance let's display a message box when the user clicks the cell's check box ( so when a checkbox is being checked ), in other words, when the cell's checkbox state is changed, so we need to handle the CellStateChanged event. Go Back.
  • Access. Select the component in design mode, Right Click, and then Select the Build Event. Select the G2antt1 component in the first drop down list, and in the second drop down list, select the CellStateChanged. The right syntax for the selected event is being generated and added to the code.
Private Sub G2antt1_CellStateChanged(ByVal Item As Long, ByVal ColIndex As Long)
    If Not (G2antt1.Items.CellState(Item, ColIndex) = 0) Then
        MsgBox "Check"
    End If
End Sub
  • VB6. In design mode, select the component, double click it. Select the G2antt1 component in the first drop down list, and in the second drop down list, select the CellStateChanged. The right syntax for the selected event is being generated and added to the code. 
Private Sub G2antt1_CellStateChanged(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long)
    If Not (G2antt1.Items.CellState(Item, ColIndex) = 0) Then
        MsgBox "Check"
    End If
End Sub
  • VFP. In design mode, select the component, double click it. Select the G2antt1 component in the first drop down list ( Object ), and in the second drop down list ( Procedure ), select the CellStateChanged. The right syntax for the selected event is being generated and added to the code.
*** ActiveX Control Event ***
LPARAMETERS item, colindex

if ( thisform.G2antt1.Items.CellState(item,colindex) # 0 )
	wait "Check" window nowait
endif
  • VB.NET ( ActiveX version ). Select the component in design mode, Click the Events page, in the Properties toolbox. Locate the CellStateChanged item in the list, and double click it. 
Private Sub AxG2antt1_CellStateChanged(ByVal sender As System.Object, _
                                       ByVal e As AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent) _
                                       Handles AxG2antt1.CellStateChanged
	If Not (AxG2antt1.Items.CellState(e.item, e.colIndex) = 0) Then
		MessageBox.Show("Check ")
	End If
End Sub
  • VB.NET ( NET Assembly ). Select the component in design mode, Click the Events page, in the Properties toolbox. Locate the CellStateChanged item in the list, and double click it. 
Private Sub Exg2antt1_CellStateChanged(ByVal sender As System.Object, _
                                       ByVal Item As System.Int32, ByVal ColIndex As System.Int32) _
                                       Handles Exg2antt1.CellStateChanged
	If Not (Exg2antt1.Items.get_CellState(Item, ColIndex) = 0) Then
		MessageBox.Show("Check")
	End If
End Sub
  • C# ( ActiveX version ). Select the component in design mode, Click the Events page, in the Properties toolbox. Locate the CellStateChanged item in the list, and double click it. 
private void axG2antt1_CellStateChanged(object sender, AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent e)
{
    if (axG2antt1.Items.get_CellState(e.item, e.colIndex) != 0)
        MessageBox.Show("Check");
}
  • C# ( NET Assembly ). Select the component in design mode, Click the Events page, in the Properties toolbox. Locate the CellStateChanged item in the list, and double click it. 
private void exg2antt1_CellStateChanged(object sender, int Item, int ColIndex)
{
    if (exg2antt1.Items.get_CellState(Item, ColIndex) != 0)
        MessageBox.Show("Check");
}
  • C++ (6.0). Select the component in design mode, Right click, and select Events in the shortcut menu. The Windows Message and Event Handlers for class dialog is opened. Locate the CellStateChanged item in the Window messages/events and click the Add and Edit button. Confirm the name of the member function, and click OK button.
void CWindowMFCDlg::OnCellStateChangedG2antt1(long Item, long ColIndex) 
{
	if ( m_g2antt.GetItems().GetCellState( COleVariant( Item ), COleVariant( ColIndex ) ) != 0 )
		AfxMessageBox( "Check" );
	
}
  • C++ (2005,2008). Select the component in design mode, Right click, and select Add Event Handler in the shortcut menu. The Event Handler Wizard dialog is opened. Locate and select the CellStateChanged item in the Message Type listbox, click the Add and Edit button. In the following sample we have used, the #import <exg2antt.dll> so the control's type library is included in the project, so the EXG2ANTTLib namespace is defined. The EXG2ANTTLib namespace defines all objects, properties and method of the control. The class wizard has inserted only a class definition for the main object, not for all the objects being exposed by the component.
#import <exg2antt.dll>
void CWindowMFCDlg::CellStateChangedG2antt1(long Item, long ColIndex)
{
	EXG2ANTTLib::IItemsPtr spItems = m_g2antt.get_Items();
	if ( spItems != NULL )
		if ( 0 != spItems->CellState[ CComVariant( Item ), CComVariant( ColIndex ) ] )
			AfxMessageBox( _T("Check") );
}
  • Clarion. Assumes that Event handler is checked. Go to OLE Event Handler and enter this code:
  •  LOOP OLE:Count = 1 TO OCXGETPARAMCOUNT(ref)
       OLE:Parametar = OCXGETPARAM(ref,OLE:Count)
     END
         CASE OLEControlFEQ{PROP:LastEventName}
         OF 'CellStateChanged'
         CASE OLE:Count
         OF 1
           OLE:Item = OLE:Parametar
         OF 2
           OLE:ColIndex = OLE:Parametar
         END
         IF NOT OLEControlFEQ{mc:Items&'.CellState('&OLE:Item&', '&OLE:ColIndex&')'} = 0
           MESSAGE('Check')
         End