exgantt - sample code

How can I add a summary bar in the chart area?

VBA (MS Access, Excell...)

With Gantt1
	.Columns.Add "Task"
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar .AddItem("Task 1"),"Summary",#1/2/2001#,#1/6/2001#
	End With
End With

VB6

With Gantt1
	.Columns.Add "Task"
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar .AddItem("Task 1"),"Summary",#1/2/2001#,#1/6/2001#
	End With
End With

VB.NET

With Exgantt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar(.AddItem("Task 1"),"Summary",#1/2/2001#,#1/6/2001#)
	End With
End With

VB.NET for /COM

With AxGantt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar(.AddItem("Task 1"),"Summary",#1/2/2001#,#1/6/2001#)
	End With
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXGANTTLib' for the library: 'ExGantt 1.0 Control Library'

	#import <ExGantt.dll>
	using namespace EXGANTTLib;
*/
EXGANTTLib::IGanttPtr spGantt1 = GetDlgItem(IDC_GANTT1)->GetControlUnknown();
spGantt1->GetColumns()->Add(L"Task");
spGantt1->GetChart()->PutFirstVisibleDate("1/1/2001");
EXGANTTLib::IItemsPtr var_Items = spGantt1->GetItems();
	var_Items->AddBar(var_Items->AddItem("Task 1"),"Summary","1/2/2001","1/6/2001",vtMissing,vtMissing);

C++ Builder

Gantt1->Columns->Add(L"Task");
Gantt1->Chart->set_FirstVisibleDate(TVariant(TDateTime(2001,1,1).operator double()));
Exganttlib_tlb::IItemsPtr var_Items = Gantt1->Items;
	var_Items->AddBar(var_Items->AddItem(TVariant("Task 1")),TVariant("Summary"),TVariant(TDateTime(2001,1,2).operator double()),TVariant(TDateTime(2001,1,6).operator double()),TNoParam(),TNoParam());

C#

exgantt1.Columns.Add("Task");
exgantt1.Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US"));
exontrol.EXGANTTLib.Items var_Items = exgantt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary",Convert.ToDateTime("1/2/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),Convert.ToDateTime("1/6/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),null,null);

JavaScript

<OBJECT classid="clsid:09C0C400-3A0F-4CD3-8B93-8D42FCE66726" id="Gantt1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
	Gantt1.Columns.Add("Task");
	Gantt1.Chart.FirstVisibleDate = "1/1/2001";
	var var_Items = Gantt1.Items;
		var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary","1/2/2001","1/6/2001",null,null);
</SCRIPT>

C# for /COM

axGantt1.Columns.Add("Task");
axGantt1.Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US"));
EXGANTTLib.Items var_Items = axGantt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary",Convert.ToDateTime("1/2/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),Convert.ToDateTime("1/6/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),null,null);

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Items;
	anytype var_Items;
	;

	super();

	exgantt1.Columns().Add("Task");
	exgantt1.Chart().FirstVisibleDate(COMVariant::createFromDate(str2Date("1/1/2001",213)));
	var_Items = exgantt1.Items(); com_Items = var_Items;
		com_Items.AddBar(com_Items.AddItem("Task 1"),"Summary",COMVariant::createFromDate(str2Date("1/2/2001",213)),COMVariant::createFromDate(str2Date("1/6/2001",213)));
}

Delphi 8 (.NET only)

with AxGantt1 do
begin
	Columns.Add('Task');
	Chart.FirstVisibleDate := '1/1/2001';
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Summary','1/2/2001','1/6/2001',Nil,Nil);
	end;
end

Delphi (standard)

with Gantt1 do
begin
	Columns.Add('Task');
	Chart.FirstVisibleDate := '1/1/2001';
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Summary','1/2/2001','1/6/2001',Null,Null);
	end;
end

VFP

with thisform.Gantt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = {^2001-1-1}
	with .Items
		.AddBar(.AddItem("Task 1"),"Summary",{^2001-1-2},{^2001-1-6})
	endwith
endwith

dBASE Plus

local oGantt,var_Items

oGantt = form.Activex1.nativeObject
oGantt.Columns.Add("Task")
oGantt.Chart.FirstVisibleDate = "01/01/2001"
var_Items = oGantt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary","01/02/2001","01/06/2001")

XBasic (Alpha Five)

Dim oGantt as P
Dim var_Items as P

oGantt = topparent:CONTROL_ACTIVEX1.activex
oGantt.Columns.Add("Task")
oGantt.Chart.FirstVisibleDate = {01/01/2001}
var_Items = oGantt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary",{01/02/2001},{01/06/2001})

Visual Objects

local var_Items as IItems

oDCOCX_Exontrol1:Columns:Add("Task")
oDCOCX_Exontrol1:Chart:FirstVisibleDate := SToD("20010101")
var_Items := oDCOCX_Exontrol1:Items
	var_Items:AddBar(var_Items:AddItem("Task 1"),"Summary",SToD("20010102"),SToD("20010106"),nil,nil)

PowerBuilder

OleObject oGantt,var_Items

oGantt = ole_1.Object
oGantt.Columns.Add("Task")
oGantt.Chart.FirstVisibleDate = 2001-01-01
var_Items = oGantt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Summary",2001-01-02,2001-01-06)

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Variant voColumns
	Get ComColumns to voColumns
	Handle hoColumns
	Get Create (RefClass(cComColumns)) to hoColumns
	Set pvComObject of hoColumns to voColumns
		Get ComAdd of hoColumns "Task" to Nothing
	Send Destroy to hoColumns
	Variant voChart
	Get ComChart to voChart
	Handle hoChart
	Get Create (RefClass(cComChart)) to hoChart
	Set pvComObject of hoChart to voChart
		Set ComFirstVisibleDate of hoChart to "1/1/2001"
	Send Destroy to hoChart
	Variant voItems
	Get ComItems to voItems
	Handle hoItems
	Get Create (RefClass(cComItems)) to hoItems
	Set pvComObject of hoItems to voItems
		Send ComAddBar of hoItems (ComAddItem(hoItems,"Task 1")) "Summary" "1/2/2001" "1/6/2001" Nothing Nothing
	Send Destroy to hoItems
End_Procedure

XBase++

#include "AppEvent.ch"
#include "ActiveX.ch"

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oGantt
	LOCAL oItems

	oForm := XbpDialog():new( AppDesktop() )
	oForm:drawingArea:clipChildren := .T.
	oForm:create( ,,{100,100}, {640,480},, .F. )
	oForm:close  := {|| PostAppEvent( xbeP_Quit )}

	oGantt := XbpActiveXControl():new( oForm:drawingArea )
	oGantt:CLSID  := "Exontrol.Gantt.1" /*{09C0C400-3A0F-4CD3-8B93-8D42FCE66726}*/
	oGantt:create(,, {10,60},{610,370} )

		oGantt:Columns():Add("Task")
		oGantt:Chart():FirstVisibleDate := "01/01/2001"
		oItems := oGantt:Items()
			oItems:AddBar(oItems:AddItem("Task 1"),"Summary","01/02/2001","01/06/2001")

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN
Copyright 1999-2017 Exontrol. All rights reserved.