Start using the /COM, /NET or /WPF component (exontrol) |
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/coding the eXG2antt component. These steps are similar for other components as well. info If the /NET is listed in the programming language name it means that the section is applied to /NET version of the component, if the /WPF is listed in the programming language name it means that the section is applied to WPF version of the component, else the COM or ActiveX version is being used. For instance, the VB.NET ( /WPF ) specifies that the /WPF component is using on VB.NET programming language. The VB.NET ( /COM ) and C# ( /COM ) indicates that the /COM or ActiveX version is using on VB.NET/C# programming language The tutorial shows adding and using the component for the following programming languages: (All) The following tutorials show:
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.
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
Private Sub UserForm_Initialize() With G2antt1 .Columns.Add ("Tasks") With .Items .AddItem "Task 1" .AddItem "Task 2" End With End With End Sub
Private Sub Form_Load() With G2antt1 .Columns.Add ("Tasks") With .Items .AddItem "Task 1" .AddItem "Task 2" End With End With End Sub
with thisform.G2antt1 .Columns.Add("Tasks") with .Items .AddItem("Task 1") .AddItem("Task 2") endwith endwith
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
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
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded With Exg2antt1 .Columns.Add("Tasks") With .Items .AddItem("Task 1") .AddItem("Task 2") End With End With End Sub
private void Form1_Load(object sender, EventArgs e) { axG2antt1.Columns.Add("Tasks"); axG2antt1.Items.AddItem("Task 1"); axG2antt1.Items.AddItem("Task 2"); }
private void Form1_Load(object sender, EventArgs e) { exg2antt1.Columns.Add("Tasks"); exg2antt1.Items.AddItem("Task 1"); exg2antt1.Items.AddItem("Task 2"); }
private void Window_Loaded(object sender, RoutedEventArgs e) { exg2antt1.Columns.Add("Tasks"); exg2antt1.Items.AddItem("Task 1"); exg2antt1.Items.AddItem("Task 2"); }
m_g2antt.GetColumns().Add("Tasks"); m_g2antt.GetItems().AddItem( COleVariant( "Task 1" ) ); m_g2antt.GetItems().AddItem( COleVariant( "Task 2" ) );
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") );
with G2antt1 do begin Columns.Add('Tasks'); with Items do begin AddItem('Task 1'); AddItem('Task 2'); end; end;
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.
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
Private Sub UserForm_Initialize() 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
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
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
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
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
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded With Exg2antt1 With .Chart .FirstVisibleDate = #1/1/2008# .LevelCount = 2 With .get_Level(0) .Label = "<b><%mmmm%></b> <%yyyy%>" .Unit = wpf.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
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"); }
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"); }
private void Window_Loaded(object sender, RoutedEventArgs e) { exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1); exg2antt1.Chart.LevelCount = 2; wpf.exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0); l.Label = "<b><%mmmm%></b> <%yyyy%>"; l.Unit = wpf.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"); }
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" ) );
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") );
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;
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.
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
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
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
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
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
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
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded With Exg2antt1 With .Chart .FirstVisibleDate = #1/1/2008# .LevelCount = 2 With .get_Level(0) .Label = "<b><%mmmm%></b> <%yyyy%>" .Unit = wpf.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
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); }
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); }
private void Window_Loaded(object sender, RoutedEventArgs e) { exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1); exg2antt1.Chart.LevelCount = 2; wpf.exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0); l.Label = "<b><%mmmm%></b> <%yyyy%>"; l.Unit = wpf.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); }
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("") );
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, "" );
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("") ); }
public void init() { COM com_Chart,com_Items,com_Level,com_Level1; anytype var_Chart,var_Items,var_Level,var_Level1; int h1,h2; ; super(); var_Chart = exg2antt1.Chart(); com_Chart = var_Chart; com_Chart.FirstVisibleDate(COMVariant::createFromDate(str2Date("1/1/2008",213))); com_Chart.LevelCount(2); var_Level = com_Chart.Level(0); com_Level = var_Level; com_Level.Label("<b><%mmmm%></b> <%yyyy%>"); com_Level.Unit(16/*exMonth*/); var_Level1 = COM::createFromObject(com_Chart.Level(1)); com_Level1 = var_Level1; com_Level1.Label("<%d%>"); exg2antt1.Columns().Add("Tasks"); var_Items = exg2antt1.Items(); com_Items = var_Items; h1 = com_Items.AddItem("Task 1"); com_Items.AddBar(h1,"Task",COMVariant::createFromDate(str2Date("1/2/2008",213)),COMVariant::createFromDate(str2Date("1/5/2008",213))); h2 = com_Items.AddItem("Task 2"); com_Items.AddBar(h2,"Task",COMVariant::createFromDate(str2Date("1/4/2008",213)),COMVariant::createFromDate(str2Date("1/8/2008",213))); com_Items.AddLink("LKey",h1,"",h2,""); }
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;
?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&',"")'}
OleObject oG2antt,var_Chart,var_Items,var_Level any h1,h2 oG2antt = ole_1.Object var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = 2008-01-01 var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 var_Chart.Level(1).Label = "<%d%>" oG2antt.Columns.Add("Tasks") var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task",2008-01-02,2008-01-05) h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task",2008-01-04,2008-01-08) var_Items.AddLink("LKey",h1,"",h2,"")
function form_onOpen local h1,h2,oG2antt,var_Chart,var_Items,var_Level,var_Level1 oG2antt = form.Activex1.nativeObject var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = "01/01/2008" var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 // var_Chart.Level(1).Label = "<%d%>" var_Level1 = var_Chart.Level(1) with (oG2antt) TemplateDef = [Dim var_Level1] TemplateDef = var_Level1 Template = [var_Level1.Label = "<%d%>"] endwith oG2antt.Columns.Add("Tasks") var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task","01/02/2008","01/05/2008") h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task","01/04/2008","01/08/2008") var_Items.AddLink("LKey",h1,"",h2,"") return
Procedure OnCreate Forward Send OnCreate Variant vChart Get ComChart to vChart Handle hoChart Get Create (RefClass(cComChart)) to hoChart Set pvComObject of hoChart to vChart Set ComFirstVisibleDate of hoChart to "1/1/2008" Set ComLevelCount of hoChart to 2 Variant vLevel0 Get ComLevel of hoChart 0 to vLevel0 Handle hoLevel0 Get Create (RefClass(cComLevel)) to hoLevel0 Set pvComObject of hoLevel0 to vLevel0 Set ComLabel of hoLevel0 to "<b><%mmmm%></b> <%yyyy%>" Set ComUnit of hoLevel0 to OLEexMonth Send Destroy to hoLevel0 Variant vLevel1 Get ComLevel of hoChart 1 to vLevel1 Handle hoLevel1 Get Create (RefClass(cComLevel)) to hoLevel1 Set pvComObject of hoLevel1 to vLevel1 Set ComLabel of hoLevel1 to "<%d%>" Send Destroy to hoLevel1 Send Destroy to hoChart Variant vColumns Get ComColumns to vColumns Handle hoColumns Get Create (RefClass(cComColumns)) to hoColumns Set pvComObject of hoColumns to vColumns Get ComAdd of hoColumns "Tasks" to Nothing Send Destroy to hoColumns Variant vItems Get ComItems to vItems Handle hoItems Get Create (RefClass(cComItems)) to hoItems Set pvComObject of hoItems to vItems HITEM h1 Get ComAddItem of hoItems "Task 1" to h1 Send ComAddBar of hoItems h1 "Task" "1/2/2008" "1/5/2008" Nothing Nothing HITEM h2 Get ComAddItem of hoItems "Task 2" to h2 Send ComAddBar of hoItems h2 "Task" "1/4/2008" "1/8/2008" Nothing Nothing Send ComAddLink of hoItems "LKey" h1 "" h2 "" Send Destroy to hoItems End_Procedure
#include "AppEvent.CH" #PRAGMA LIBRARY( "ASCOM10.LIB" ) // Include the Automation Support Library PROCEDURE Main LOCAL oForm, oControl LOCAL nEvent LOCAL mp1 := NIL, mp2 := NIL, oXbp := NIL LOCAL oLevel LOCAL oItems LOCAL h1, h2 oForm := XbpDialog():new( AppDesktop() ) oForm:drawingArea:clipChildren := .T. oForm:create( ,,{100,100}, {640,480},, .F. ) oForm:close := {|| PostAppEvent( xbeP_Quit )} oControl := XbpActiveXControl():new( oForm:drawingArea ) oControl:CLSID := "Exontrol.G2antt" oControl:create(,, {10,60},{610,370} ) oControl:Chart:FirstVisibleDate = "1/1/2008" oControl:Chart:LevelCount := 2 oLevel = oControl:Chart:Level(0) oLevel:Label := "<b><%mmmm%></b> <%yyyy%>" oLevel:Unit := 16 /*exMonth*/ oControl:Chart:Level(1):Label = "<%d%>" oControl:Columns:Add("Tasks") oItems := oControl:Items h1 := oItems:AddItem("Task 1") oItems:AddBar(h1, "Task", "1/2/2008", "1/5/2008") h2 := oItems:AddItem("Task 1") oItems:AddBar(h2, "Task", "1/4/2008", "1/8/2008") oItems:AddLink("LKey", h1, "", h2, "") oForm:Show() nEvent := 0 DO WHILE nEvent != xbeP_Quit nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO RETURN 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 )
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
Private Sub UserForm_Initialize() 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
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
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
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
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
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded With Exg2antt1 With .Chart .FirstVisibleDate = #1/1/2008# .LevelCount = 2 With .get_Level(0) .Label = "<b><%mmmm%></b> <%yyyy%>" .Unit = wpf.exontrol.EXG2ANTTLib.UnitEnum.exMonth End With .get_Level(1).Label = "<%d%>" .OverviewVisible = True .HistogramVisible = True .HistogramView = wpf.exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems .HistogramHeight = 32 .Bars("Task").HistogramPattern = wpf.exontrol.EXG2ANTTLib.PatternEnum.exPatternDot End With .Columns.Add("Tasks").set_Def(wpf.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
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); }
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); }
private void Window_Loaded(object sender, RoutedEventArgs e) { exg2antt1.Chart.FirstVisibleDate = new DateTime(2008, 1, 1); exg2antt1.Chart.LevelCount = 2; wpf.exontrol.EXG2ANTTLib.Level l = exg2antt1.Chart.get_Level(0); l.Label = "<b><%mmmm%></b> <%yyyy%>"; l.Unit = wpf.exontrol.EXG2ANTTLib.UnitEnum.exMonth; exg2antt1.Chart.get_Level(1).Label = "<%d%>"; exg2antt1.Chart.OverviewVisible = true; exg2antt1.Chart.HistogramVisible = true; exg2antt1.Chart.HistogramView = wpf.exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems; exg2antt1.Chart.HistogramHeight = 32; exg2antt1.Chart.Bars["Task"].HistogramPattern = wpf.exontrol.EXG2ANTTLib.PatternEnum.exPatternDot; exg2antt1.Columns.Add("Tasks").set_Def(wpf.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); }
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("") );
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, "" );
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("") ); }
public void init() { COM com_Bar,com_Chart,com_Items,com_Level,com_Level1; anytype var_Bar,var_Chart,var_Items,var_Level,var_Level1; int h1,h2; ; super(); var_Chart = exg2antt1.Chart(); com_Chart = var_Chart; com_Chart.FirstVisibleDate(COMVariant::createFromDate(str2Date("1/1/2008",213))); com_Chart.LevelCount(2); var_Level = com_Chart.Level(0); com_Level = var_Level; com_Level.Label("<b><%mmmm%></b> <%yyyy%>"); com_Level.Unit(16/*exMonth*/); var_Level1 = COM::createFromObject(com_Chart.Level(1)); com_Level1 = var_Level1; com_Level1.Label("<%d%>"); com_Chart.OverviewVisible(true); com_Chart.HistogramVisible(true); com_Chart.HistogramView(4/*exHistogramCheckedItems*/); com_Chart.HistogramHeight(32); var_Bar = COM::createFromObject(com_Chart.Bars()).Item("Task"); com_Bar = var_Bar; com_Bar.HistogramPattern(2/*exPatternDot*/); COM::createFromVariant(exg2antt1.Columns().Add("Tasks")).Def(0/*exCellHasCheckBox*/,COMVariant::createFromBoolean(true)); var_Items = exg2antt1.Items(); com_Items = var_Items; h1 = com_Items.AddItem("Task 1"); com_Items.AddBar(h1,"Task",COMVariant::createFromDate(str2Date("1/2/2008",213)),COMVariant::createFromDate(str2Date("1/5/2008",213))); h2 = com_Items.AddItem("Task 2"); com_Items.AddBar(h2,"Task",COMVariant::createFromDate(str2Date("1/4/2008",213)),COMVariant::createFromDate(str2Date("1/8/2008",213))); com_Items.AddLink("LKey",h1,"",h2,""); }
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;
?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&',"")'}
OleObject oG2antt,var_Chart,var_Items,var_Level any h1,h2 oG2antt = ole_1.Object var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = 2008-01-01 var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 var_Chart.Level(1).Label = "<%d%>" var_Chart.OverviewVisible = true var_Chart.HistogramVisible = true var_Chart.HistogramView = 4 var_Chart.HistogramHeight = 32 var_Chart.Bars.Item("Task").HistogramPattern = 2 oG2antt.Columns.Add("Tasks").Def(0,true) var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task",2008-01-02,2008-01-05) h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task",2008-01-04,2008-01-08) var_Items.AddLink("LKey",h1,"",h2,"")
function form_onOpen local h1,h2,oG2antt,var_Chart,var_Column,var_Items,var_Level,var_Level1 oG2antt = form.Activex1.nativeObject var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = "01/01/2008" var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 // var_Chart.Level(1).Label = "<%d%>" var_Level1 = var_Chart.Level(1) with (oG2antt) TemplateDef = [Dim var_Level1] TemplateDef = var_Level1 Template = [var_Level1.Label = "<%d%>"] endwith var_Chart.OverviewVisible = true var_Chart.HistogramVisible = true var_Chart.HistogramView = 4 var_Chart.HistogramHeight = 32 var_Chart.Bars.Item("Task").HistogramPattern = 2 // oG2antt.Columns.Add("Tasks").Def(0) = true var_Column = oG2antt.Columns.Add("Tasks") with (oG2antt) TemplateDef = [Dim var_Column] TemplateDef = var_Column Template = [var_Column.Def(0) = true] endwith var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task","01/02/2008","01/05/2008") h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task","01/04/2008","01/08/2008") var_Items.AddLink("LKey",h1,"",h2,"") return
Procedure OnCreate Forward Send OnCreate Variant vChart Get ComChart to vChart Handle hoChart Get Create (RefClass(cComChart)) to hoChart Set pvComObject of hoChart to vChart Set ComFirstVisibleDate of hoChart to "1/1/2008" Set ComLevelCount of hoChart to 2 Variant vLevel0 Get ComLevel of hoChart 0 to vLevel0 Handle hoLevel0 Get Create (RefClass(cComLevel)) to hoLevel0 Set pvComObject of hoLevel0 to vLevel0 Set ComLabel of hoLevel0 to "<b><%mmmm%></b> <%yyyy%>" Set ComUnit of hoLevel0 to OLEexMonth Send Destroy to hoLevel0 Variant vLevel1 Get ComLevel of hoChart 1 to vLevel1 Handle hoLevel1 Get Create (RefClass(cComLevel)) to hoLevel1 Set pvComObject of hoLevel1 to vLevel1 Set ComLabel of hoLevel1 to "<%d%>" Send Destroy to hoLevel1 Set ComOverviewVisible of hoChart to True Set ComHistogramVisible of hoChart to True Set ComHistogramView of hoChart to OLEexHistogramCheckedItems Set ComHistogramHeight of hoChart to 32 Variant vBars Get ComBars of hoChart to vBars Handle hoBars Get Create (RefClass(cComBars)) to hoBars Set pvComObject of hoBars to vBars Variant vBar Get ComItem of hoBars "Task" to vBar Handle hoBar Get Create (RefClass(cComBar)) to hoBar Set pvComObject of hoBar to vBar Set ComHistogramPattern of hoBar to OLEexPatternDot Send Destroy to hoBar Send Destroy to hoBars Send Destroy to hoChart Variant vColumns Get ComColumns to vColumns Handle hoColumns Get Create (RefClass(cComColumns)) to hoColumns Set pvComObject of hoColumns to vColumns Variant vColumn Get ComAdd of hoColumns "Tasks" to vColumn Handle hoColumn Get Create (RefClass(cComColumn)) to hoColumn Set pvComObject of hoColumn to vColumn Set ComDef of hoColumn OLEexCellHasCheckBox to True Send Destroy to hoColumn Send Destroy to hoColumns Variant vItems Get ComItems to vItems Handle hoItems Get Create (RefClass(cComItems)) to hoItems Set pvComObject of hoItems to vItems HITEM h1 Get ComAddItem of hoItems "Task 1" to h1 Send ComAddBar of hoItems h1 "Task" "1/2/2008" "1/5/2008" Nothing Nothing HITEM h2 Get ComAddItem of hoItems "Task 2" to h2 Send ComAddBar of hoItems h2 "Task" "1/4/2008" "1/8/2008" Nothing Nothing Send ComAddLink of hoItems "LKey" h1 "" h2 "" Send Destroy to hoItems End_Procedure
#include "AppEvent.CH" #PRAGMA LIBRARY( "ASCOM10.LIB" ) // Include the Automation Support Library PROCEDURE Main LOCAL oForm, oControl LOCAL nEvent LOCAL mp1 := NIL, mp2 := NIL, oXbp := NIL LOCAL oLevel LOCAL oItems LOCAL h1, h2 oForm := XbpDialog():new( AppDesktop() ) oForm:drawingArea:clipChildren := .T. oForm:create( ,,{100,100}, {640,480},, .F. ) oForm:close := {|| PostAppEvent( xbeP_Quit )} oControl := XbpActiveXControl():new( oForm:drawingArea ) oControl:CLSID := "Exontrol.G2antt" oControl:create(,, {10,60},{610,370} ) oControl:Chart:FirstVisibleDate = "1/1/2008" oControl:Chart:LevelCount := 2 oLevel = oControl:Chart:Level(0) oLevel:Label := "<b><%mmmm%></b> <%yyyy%>" oLevel:Unit := 16 /*exMonth*/ oControl:Chart:Level(1):Label = "<%d%>" oControl:Chart:OverviewVisible = -1 /*exOverviewShowAll*/ oControl:Chart:HistogramVisible = .T. oControl:Chart:HistogramView = 4 /*exHistogramCheckedItems*/ oControl:Chart:HistogramHeight = 32 oControl:Chart:Bars("Task"):HistogramPattern = 2 /*exPatternDot*/ oControl:Columns:Add("Tasks"):SetProperty("Def", 0 /*exCellHasCheckBox*/, .T.) oItems := oControl:Items h1 := oItems:AddItem("Task 1") oItems:AddBar(h1, "Task", "1/2/2008", "1/5/2008") h2 := oItems:AddItem("Task 1") oItems:AddBar(h2, "Task", "1/4/2008", "1/8/2008") oItems:AddLink("LKey", h1, "", h2, "") oForm:Show() nEvent := 0 DO WHILE nEvent != xbeP_Quit nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO RETURN 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.
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
Private Sub UserForm_Initialize() 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
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
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
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
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
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded With Exg2antt1 .BeginUpdate() With .Chart .FirstVisibleDate = #1/1/2008# .LevelCount = 2 With .get_Level(0) .Label = "<b><%mmmm%></b> <%yyyy%>" .Unit = wpf.exontrol.EXG2ANTTLib.UnitEnum.exMonth End With .get_Level(1).Label = "<%d%>" .OverviewVisible = True .HistogramVisible = True .HistogramView = wpf.exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems .HistogramHeight = 32 .Bars("Task").HistogramPattern = wpf.exontrol.EXG2ANTTLib.PatternEnum.exPatternDot End With .Columns.Add("Tasks").set_Def(wpf.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
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(); }
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(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { exg2antt1.BeginUpdate(); wpf.exontrol.EXG2ANTTLib.Chart chart = exg2antt1.Chart; chart.FirstVisibleDate = new DateTime(2008, 1, 1); chart.LevelCount = 2; wpf.exontrol.EXG2ANTTLib.Level l = chart.get_Level(0); l.Label = "<b><%mmmm%></b> <%yyyy%>"; l.Unit = wpf.exontrol.EXG2ANTTLib.UnitEnum.exMonth; chart.get_Level(1).Label = "<%d%>"; chart.OverviewVisible = true; chart.HistogramVisible = true; chart.HistogramView = wpf.exontrol.EXG2ANTTLib.HistogramViewEnum.exHistogramCheckedItems; chart.HistogramHeight = 32; chart.Bars["Task"].HistogramPattern = wpf.exontrol.EXG2ANTTLib.PatternEnum.exPatternDot; exg2antt1.Columns.Add("Tasks").set_Def(wpf.exontrol.EXG2ANTTLib.DefColumnEnum.exCellHasCheckBox, true); wpf.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(); }
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();
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();
public void init() { COM com_Bar,com_Chart,com_Items,com_Level,com_Level1; anytype var_Bar,var_Chart,var_Items,var_Level,var_Level1; int h1,h2; ; super(); exg2antt1.BeginUpdate(); var_Chart = exg2antt1.Chart(); com_Chart = var_Chart; com_Chart.FirstVisibleDate(COMVariant::createFromDate(str2Date("1/1/2008",213))); com_Chart.LevelCount(2); var_Level = com_Chart.Level(0); com_Level = var_Level; com_Level.Label("<b><%mmmm%></b> <%yyyy%>"); com_Level.Unit(16/*exMonth*/); var_Level1 = COM::createFromObject(com_Chart.Level(1)); com_Level1 = var_Level1; com_Level1.Label("<%d%>"); com_Chart.OverviewVisible(true); com_Chart.HistogramVisible(true); com_Chart.HistogramView(4/*exHistogramCheckedItems*/); com_Chart.HistogramHeight(32); var_Bar = COM::createFromObject(com_Chart.Bars()).Item("Task"); com_Bar = var_Bar; com_Bar.HistogramPattern(2/*exPatternDot*/); COM::createFromVariant(exg2antt1.Columns().Add("Tasks")).Def(0/*exCellHasCheckBox*/,COMVariant::createFromBoolean(true)); var_Items = exg2antt1.Items(); com_Items = var_Items; h1 = com_Items.AddItem("Task 1"); com_Items.AddBar(h1,"Task",COMVariant::createFromDate(str2Date("1/2/2008",213)),COMVariant::createFromDate(str2Date("1/5/2008",213))); h2 = com_Items.AddItem("Task 2"); com_Items.AddBar(h2,"Task",COMVariant::createFromDate(str2Date("1/4/2008",213)),COMVariant::createFromDate(str2Date("1/8/2008",213))); com_Items.AddLink("LKey",h1,"",h2,""); exg2antt1.EndUpdate(); } 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(); }
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;
?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'}
OleObject oG2antt,var_Chart,var_Items,var_Level any h1,h2 oG2antt = ole_1.Object oG2antt.BeginUpdate() var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = 2008-01-01 var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 var_Chart.Level(1).Label = "<%d%>" var_Chart.OverviewVisible = true var_Chart.HistogramVisible = true var_Chart.HistogramView = 4 var_Chart.HistogramHeight = 32 var_Chart.Bars.Item("Task").HistogramPattern = 2 oG2antt.Columns.Add("Tasks").Def(0,true) var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task",2008-01-02,2008-01-05) h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task",2008-01-04,2008-01-08) var_Items.AddLink("LKey",h1,"",h2,"") oG2antt.EndUpdate()
function form_onOpen local h1,h2,oG2antt,var_Chart,var_Column,var_Items,var_Level,var_Level1 oG2antt = form.Activex1.nativeObject oG2antt.BeginUpdate() var_Chart = oG2antt.Chart var_Chart.FirstVisibleDate = "01/01/2008" var_Chart.LevelCount = 2 var_Level = var_Chart.Level(0) var_Level.Label = "<b><%mmmm%></b> <%yyyy%>" var_Level.Unit = 16 // var_Chart.Level(1).Label = "<%d%>" var_Level1 = var_Chart.Level(1) with (oG2antt) TemplateDef = [Dim var_Level1] TemplateDef = var_Level1 Template = [var_Level1.Label = "<%d%>"] endwith var_Chart.OverviewVisible = true var_Chart.HistogramVisible = true var_Chart.HistogramView = 4 var_Chart.HistogramHeight = 32 var_Chart.Bars.Item("Task").HistogramPattern = 2 // oG2antt.Columns.Add("Tasks").Def(0) = true var_Column = oG2antt.Columns.Add("Tasks") with (oG2antt) TemplateDef = [Dim var_Column] TemplateDef = var_Column Template = [var_Column.Def(0) = true] endwith var_Items = oG2antt.Items h1 = var_Items.AddItem("Task 1") var_Items.AddBar(h1,"Task","01/02/2008","01/05/2008") h2 = var_Items.AddItem("Task 2") var_Items.AddBar(h2,"Task","01/04/2008","01/08/2008") var_Items.AddLink("LKey",h1,"",h2,"") oG2antt.EndUpdate() return
Procedure OnCreate Forward Send OnCreate Send ComBeginUpdate Variant vChart Get ComChart to vChart Handle hoChart Get Create (RefClass(cComChart)) to hoChart Set pvComObject of hoChart to vChart Set ComFirstVisibleDate of hoChart to "1/1/2008" Set ComLevelCount of hoChart to 2 Variant vLevel0 Get ComLevel of hoChart 0 to vLevel0 Handle hoLevel0 Get Create (RefClass(cComLevel)) to hoLevel0 Set pvComObject of hoLevel0 to vLevel0 Set ComLabel of hoLevel0 to "<b><%mmmm%></b> <%yyyy%>" Set ComUnit of hoLevel0 to OLEexMonth Send Destroy to hoLevel0 Variant vLevel1 Get ComLevel of hoChart 1 to vLevel1 Handle hoLevel1 Get Create (RefClass(cComLevel)) to hoLevel1 Set pvComObject of hoLevel1 to vLevel1 Set ComLabel of hoLevel1 to "<%d%>" Send Destroy to hoLevel1 Set ComOverviewVisible of hoChart to True Set ComHistogramVisible of hoChart to True Set ComHistogramView of hoChart to OLEexHistogramCheckedItems Set ComHistogramHeight of hoChart to 32 Variant vBars Get ComBars of hoChart to vBars Handle hoBars Get Create (RefClass(cComBars)) to hoBars Set pvComObject of hoBars to vBars Variant vBar Get ComItem of hoBars "Task" to vBar Handle hoBar Get Create (RefClass(cComBar)) to hoBar Set pvComObject of hoBar to vBar Set ComHistogramPattern of hoBar to OLEexPatternDot Send Destroy to hoBar Send Destroy to hoBars Send Destroy to hoChart Variant vColumns Get ComColumns to vColumns Handle hoColumns Get Create (RefClass(cComColumns)) to hoColumns Set pvComObject of hoColumns to vColumns Variant vColumn Get ComAdd of hoColumns "Tasks" to vColumn Handle hoColumn Get Create (RefClass(cComColumn)) to hoColumn Set pvComObject of hoColumn to vColumn Set ComDef of hoColumn OLEexCellHasCheckBox to True Send Destroy to hoColumn Send Destroy to hoColumns Variant vItems Get ComItems to vItems Handle hoItems Get Create (RefClass(cComItems)) to hoItems Set pvComObject of hoItems to vItems HITEM h1 Get ComAddItem of hoItems "Task 1" to h1 Send ComAddBar of hoItems h1 "Task" "1/2/2008" "1/5/2008" Nothing Nothing HITEM h2 Get ComAddItem of hoItems "Task 2" to h2 Send ComAddBar of hoItems h2 "Task" "1/4/2008" "1/8/2008" Nothing Nothing Send ComAddLink of hoItems "LKey" h1 "" h2 "" Send Destroy to hoItems Send ComEndUpdate End_Procedure
#include "AppEvent.CH" #PRAGMA LIBRARY( "ASCOM10.LIB" ) // Include the Automation Support Library PROCEDURE Main LOCAL oForm, oControl LOCAL nEvent LOCAL mp1 := NIL, mp2 := NIL, oXbp := NIL LOCAL oLevel LOCAL oItems LOCAL h1, h2 oForm := XbpDialog():new( AppDesktop() ) oForm:drawingArea:clipChildren := .T. oForm:create( ,,{100,100}, {640,480},, .F. ) oForm:close := {|| PostAppEvent( xbeP_Quit )} oControl := XbpActiveXControl():new( oForm:drawingArea ) oControl:CLSID := "Exontrol.G2antt" oControl:create(,, {10,60},{610,370} ) oControl:BeginUpdate() oControl:Chart:FirstVisibleDate = "1/1/2008" oControl:Chart:LevelCount := 2 oLevel = oControl:Chart:Level(0) oLevel:Label := "<b><%mmmm%></b> <%yyyy%>" oLevel:Unit := 16 /*exMonth*/ oControl:Chart:Level(1):Label = "<%d%>" oControl:Chart:OverviewVisible = -1 /*exOverviewShowAll*/ oControl:Chart:HistogramVisible = .T. oControl:Chart:HistogramView = 4 /*exHistogramCheckedItems*/ oControl:Chart:HistogramHeight = 32 oControl:Chart:Bars("Task"):HistogramPattern = 2 /*exPatternDot*/ oControl:Columns:Add("Tasks"):SetProperty("Def", 0 /*exCellHasCheckBox*/, .T.) oItems := oControl:Items h1 := oItems:AddItem("Task 1") oItems:AddBar(h1, "Task", "1/2/2008", "1/5/2008") h2 := oItems:AddItem("Task 1") oItems:AddBar(h2, "Task", "1/4/2008", "1/8/2008") oItems:AddLink("LKey", h1, "", h2, "") oControl:EndUpdate() oForm:Show() nEvent := 0 DO WHILE nEvent != xbeP_Quit nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO RETURN
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
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 UserForm_Initialize() init G2antt1 End Sub
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
LPARAMETER g With g .BeginUpdate .Columns.Add ("Tasks") With .Items .AddItem("Task 1") .AddItem("Task 2") EndWith .EndUpdate EndWiththisform.initC(thisform.G2antt1)
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
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
Private Sub init(ByVal g As wpf.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 Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded Call init(Exg2antt1) End Sub
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); }
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); }
private void init(wpf.exontrol.EXG2ANTTLib.exg2antt g) { g.BeginUpdate(); g.Columns.Add("Tasks"); g.Items.AddItem("Task 1"); g.Items.AddItem("Task 2"); g.EndUpdate(); } private void Window_Loaded(object sender, RoutedEventArgs e) { init(exg2antt1); }
#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);
#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() );
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);
public void init() { COM com_Items; anytype var_Items; ; super(); exg2antt1.BeginUpdate(); exg2antt1.Columns().Add("Tasks"); var_Items = exg2antt1.Items(); com_Items = var_Items; com_Items.AddItem("Task 1"); com_Items.AddItem("Task 2"); exg2antt1.EndUpdate(); }
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;
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
// init( olecustomcontrol g ) returns (none) OleObject oG2antt,var_Items oG2antt = g.Object oG2antt.BeginUpdate() oG2antt.Columns.Add("Tasks") var_Items = oG2antt.Items var_Items.AddItem("Task 1") var_Items.AddItem("Task 2") oG2antt.EndUpdate()
function init(o) o.Columns.Add("Tasks") var_Items = o.Items var_Items.AddItem("Task 1") var_Items.AddItem("Task 2") return
Procedure init Handle g Variant vColumns Get ComColumns of g to vColumns Handle hoColumns Get Create (RefClass(cComColumns)) to hoColumns Set pvComObject of hoColumns to vColumns Get ComAdd of hoColumns "Tasks" to Nothing Send Destroy to hoColumns Variant vItems Get ComItems of g to vItems Handle hoItems Get Create (RefClass(cComItems)) to hoItems Set pvComObject of hoItems to vItems Get ComAddItem of hoItems "Task 1" to Nothing Get ComAddItem of hoItems "Task 2" to Nothing Send Destroy to hoItems End_Procedure
PROCEDURE _init( oControl ) oControl:BeginUpdate() oControl:Columns:Add("Tasks") oControl:Items:AddItem("Task 1") oControl:Items:AddItem("Task 2") oControl:EndUpdate() RETURN
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.
Private Sub callPreview() With Print1 Set .PrintExt = G2antt1.Object .preview End With End Sub
Private Sub callPreview() With Print1 Set .PrintExt = G2antt1 .Preview End With End Sub
Private Sub callPreview() With Print1 Set .PrintExt = G2antt1.Object .Preview End With End Sub
with thisform.Print1 .PrintExt = thisform.G2antt1.Object .Preview endwith
Private Sub callPreview() With AxPrint1 .PrintExt = AxG2antt1.GetOcx() .Preview() End With End Sub
Private Sub callPreview() With Exprint1 .PrintExt = Exg2antt1 .Preview() End With End Sub
Private exprint As exontrol.EXPRINTLib.exprint = New exontrol.EXPRINTLib.exprint() Private Sub callPreview() With exprint .PrintExt = Exg2antt1 .Preview() End With End Sub
private void callPreview() { axPrint1.PrintExt = axG2antt1.GetOcx(); axPrint1.Preview(); }
private void callPreview() { exprint1.PrintExt = exg2antt1; exprint1.Preview(); }
exontrol.EXPRINTLib.exprint exprint = new exontrol.EXPRINTLib.exprint(); private void callPreview() { exprint.PrintExt = exg2antt1; exprint.Preview(); }
void CWindowMFCDlg::callPreview() { m_print.SetPrintExt( m_g2antt.GetControlUnknown() ); m_print.Preview(); }
void CWindowMFCDlg::callPreview() { m_print.put_PrintExt( m_g2antt.GetControlUnknown() ); m_print.Preview(); }
void TForm1::callPreview() { Print1->PrintExt = G2antt1->DefaultDispatch; Print1->Preview(); }
void callPreview() { anytype var_object; ; var_object = exg2antt1; exprint1.PrintExt(var_object); exprint1.Preview(); }
procedure callPreview(P : TPrint; G : TG2antt); begin with P do begin PrintExt := G.DefaultDispatch; Preview(); end; end;callPreview( Print1, G2antt1 );
?Print{'Settings(10)'} = 1 ?Print{'PrintExt'} = ?Gantt{PROP:Object} ! If we going to print ExG2antt ?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 _preview method when you need ie clicking a button, save and run the project. Once the +preview 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 ( /COM or ActiveX versions ), 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:
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 ' defines comments in the x-script, so it should not be confused with " or ` characters. The Template supports the following general functions:
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.
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
Private Sub G2antt1_CellStateChanged(ByVal Item As EXG2ANTTLib.HITEM, ByVal ColIndex As Long) If Not (G2antt1.Items.CellState(Item, ColIndex) = 0) Then MsgBox "Check" End If End Sub
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
*** ActiveX Control Event *** LPARAMETERS item, colindex if ( thisform.G2antt1.Items.CellState(item,colindex) # 0 ) wait "Check" window nowait endif
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
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
Private Sub Exg2antt1_CellStateChanged(ByVal sender As System.Object, ByVal Item As System.Int32, ByVal ColIndex As System.Int32) If Not (Exg2antt1.Items.get_CellState(Item, ColIndex) = 0) Then MessageBox.Show("Check") End If End Sub
private void axG2antt1_CellStateChanged(object sender, AxEXG2ANTTLib._IG2anttEvents_CellStateChangedEvent e) { if (axG2antt1.Items.get_CellState(e.item, e.colIndex) != 0) MessageBox.Show("Check"); }
private void exg2antt1_CellStateChanged(object sender, int Item, int ColIndex) { if (exg2antt1.Items.get_CellState(Item, ColIndex) != 0) MessageBox.Show("Check"); }
private void exg2antt1_CellStateChanged(object sender, int Item, int ColIndex) { if (exg2antt1.Items.get_CellState(Item, ColIndex) != 0) MessageBox.Show("Check"); }
void CWindowMFCDlg::OnCellStateChangedG2antt1(long Item, long ColIndex) { if ( m_g2antt.GetItems().GetCellState( COleVariant( Item ), COleVariant( ColIndex ) ) != 0 ) AfxMessageBox( "Check" ); }
#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") ); }
// Fired after cell's state has been changed. void onEvent_CellStateChanged(int _Item, int _ColIndex) { ; if ( exg2antt1.Items().CellState(_Item,_ColIndex) != 0 ) Global::info("Check"); }
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
//cellstatechanged( long item, long colindex ) OLEObject oG2antt oG2antt = ole_1.Object if ( oG2antt.Items.CellState(item,colindex) <> 0 ) then MessageBox("info","check") end if
function nativeObject_CellStateChanged(Item, ColIndex) local oG2antt oG2antt = form.Activex1.nativeObject if ( oG2antt.Items.CellState(Item,ColIndex) <> 0 ) msgbox("check") endif return
Procedure OnComCellStateChanged HITEM llItem Integer llColIndex Forward Send OnComCellStateChanged llItem llColIndex Variant vItems Get ComItems to vItems Handle hoItems Get Create (RefClass(cComItems)) to hoItems Set pvComObject of hoItems to vItems Integer c Get ComCellState of hoItems llItem llColIndex to c Send Destroy to hoItems If (not ( c = 0 )) Begin Send Info_Box "click" End End_Procedure
... oControl:cellStateChanged := { | Item, ColIndex | OnCellStateChanged(oControl,Item,ColIndex) } ... |