property Chart.AllowNonworkingBars as Boolean
Specifies whether the chart treats bars with exBarTreatAsNonworking as non-working parts of the item.

 TypeDescription 
   Boolean A Boolean expression that specifies whether the bars with exBarTreatAsNonworking set on True indicate non-working parts of the items.  
By default, the AllowNonworkingBars property is False. The chart supports bars that may indicates non-working parts of the items where they are hosted. The AllowNonworkingBars  have effect only for bar with exBarTreatAsNonworking set on True hosted on an item with the ItemNonworkingUnits property points to a not empty and valid expression. For instance, if the bar with exBarTreatAsNonworking is hosted to an item that has ItemNonworkingUnits property on empty ( by default ) it is treated as a normal bar. Use the ShowNonworkingUnits property to hide the non-working units. Use the ShowNonworkingDates property to specify whether the the days are shown or hidden while the ShowNonworkingUnits property is False. 

The control supports the following ways of specify the non-working parts for items:

In conclusion, a bar is treated as a non-working part inside the item if:

The following screen shot shows a "holidays" bar that indicates the non-working parts of the item where it is hosted:

In this sample you can notice that all bars preserves their length ( working part ),  while the "holidays" or any other bar bar is moving.

The following samples adds a bar to be treated as a nonworking part like a "holidays" bar:

VBA (MS Access, Excel...)

With G2antt1
	.BeginUpdate 
	With .Chart
		.FirstVisibleDate = #1/1/2001#
		.LevelCount = 2
		.PaneWidth(False) = 48
		.AllowNonworkingBars = True
		0.Bars.Add("Task:Split").Shortcut = "Task"
	End With
	.Columns.Add "Tasks"
	With .Items
		h = .AddItem("Task 1")
		.ItemNonworkingUnits(h,False) = "weekday(value) in (0,6)"
		.AddBar h,"",#1/2/2001#,#1/5/2001#,"A","holyday"
		.ItemBar(h,"A",38) = True
		.AddBar h,"Task",#1/5/2001#,#1/12/2001#,"Z"
		.ItemBar(h,"Z",20) = True
	End With
	.EndUpdate 
End With

VB6

With G2antt1
	.BeginUpdate 
	With .Chart
		.FirstVisibleDate = #1/1/2001#
		.LevelCount = 2
		.PaneWidth(False) = 48
		.AllowNonworkingBars = True
		0.Bars.Add("Task:Split").Shortcut = "Task"
	End With
	.Columns.Add "Tasks"
	With .Items
		h = .AddItem("Task 1")
		.ItemNonworkingUnits(h,False) = "weekday(value) in (0,6)"
		.AddBar h,"",#1/2/2001#,#1/5/2001#,"A","holyday"
		.ItemBar(h,"A",exBarTreatAsNonworking) = True
		.AddBar h,"Task",#1/5/2001#,#1/12/2001#,"Z"
		.ItemBar(h,"Z",exBarKeepWorkingCount) = True
	End With
	.EndUpdate 
End With

VB.NET

Dim h
With Exg2antt1
	.BeginUpdate()
	With .Chart
		.FirstVisibleDate = #1/1/2001#
		.LevelCount = 2
		.set_PaneWidth(False,48)
		.AllowNonworkingBars = True
		0.Bars.Add("Task:Split").Shortcut = "Task"
	End With
	.Columns.Add("Tasks")
	With .Items
		h = .AddItem("Task 1")
		.set_ItemNonworkingUnits(h,False,"weekday(value) in (0,6)")
		.AddBar(h,"",#1/2/2001#,#1/5/2001#,"A","holyday")
		.set_ItemBar(h,"A",exontrol.EXG2ANTTLib.ItemBarPropertyEnum.exBarTreatAsNonworking,True)
		.AddBar(h,"Task",#1/5/2001#,#1/12/2001#,"Z")
		.set_ItemBar(h,"Z",exontrol.EXG2ANTTLib.ItemBarPropertyEnum.exBarKeepWorkingCount,True)
	End With
	.EndUpdate()
End With

VB.NET for /COM

Dim h
With AxG2antt1
	.BeginUpdate()
	With .Chart
		.FirstVisibleDate = #1/1/2001#
		.LevelCount = 2
		.PaneWidth(False) = 48
		.AllowNonworkingBars = True
		0.Bars.Add("Task:Split").Shortcut = "Task"
	End With
	.Columns.Add("Tasks")
	With .Items
		h = .AddItem("Task 1")
		.ItemNonworkingUnits(h,False) = "weekday(value) in (0,6)"
		.AddBar(h,"",#1/2/2001#,#1/5/2001#,"A","holyday")
		.ItemBar(h,"A",EXG2ANTTLib.ItemBarPropertyEnum.exBarTreatAsNonworking) = True
		.AddBar(h,"Task",#1/5/2001#,#1/12/2001#,"Z")
		.ItemBar(h,"Z",EXG2ANTTLib.ItemBarPropertyEnum.exBarKeepWorkingCount) = True
	End With
	.EndUpdate()
End With

C++

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

	#import <ExG2antt.dll>
	using namespace EXG2ANTTLib;
*/
EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
spG2antt1->BeginUpdate();
EXG2ANTTLib::IChartPtr var_Chart = spG2antt1->GetChart();
	var_Chart->PutFirstVisibleDate("1/1/2001");
	var_Chart->PutLevelCount(2);
	var_Chart->PutPaneWidth(VARIANT_FALSE,48);
	var_Chart->PutAllowNonworkingBars(VARIANT_TRUE);
	0var_Chart->GetBars()->Add(L"Task:Split")->PutShortcut(L"Task");
spG2antt1->GetColumns()->Add(L"Tasks");
EXG2ANTTLib::IItemsPtr var_Items = spG2antt1->GetItems();
	long h = var_Items->AddItem("Task 1");
	var_Items->PutItemNonworkingUnits(h,VARIANT_FALSE,L"weekday(value) in (0,6)");
	var_Items->AddBar(h,"","1/2/2001","1/5/2001","A","holyday");
	var_Items->PutItemBar(h,"A",EXG2ANTTLib::exBarTreatAsNonworking,VARIANT_TRUE);
	var_Items->AddBar(h,"Task","1/5/2001","1/12/2001","Z",vtMissing);
	var_Items->PutItemBar(h,"Z",EXG2ANTTLib::exBarKeepWorkingCount,VARIANT_TRUE);
spG2antt1->EndUpdate();

C#

exg2antt1.BeginUpdate();
exontrol.EXG2ANTTLib.Chart var_Chart = exg2antt1.Chart;
	var_Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001");
	var_Chart.LevelCount = 2;
	var_Chart.set_PaneWidth(false,48);
	var_Chart.AllowNonworkingBars = true;
	0var_Chart.Bars.Add("Task:Split").Shortcut = "Task";
exg2antt1.Columns.Add("Tasks");
exontrol.EXG2ANTTLib.Items var_Items = exg2antt1.Items;
	int h = var_Items.AddItem("Task 1");
	var_Items.set_ItemNonworkingUnits(h,false,"weekday(value) in (0,6)");
	var_Items.AddBar(h,"",Convert.ToDateTime("1/2/2001"),Convert.ToDateTime("1/5/2001"),"A","holyday");
	var_Items.set_ItemBar(h,"A",exontrol.EXG2ANTTLib.ItemBarPropertyEnum.exBarTreatAsNonworking,true);
	var_Items.AddBar(h,"Task",Convert.ToDateTime("1/5/2001"),Convert.ToDateTime("1/12/2001"),"Z",null);
	var_Items.set_ItemBar(h,"Z",exontrol.EXG2ANTTLib.ItemBarPropertyEnum.exBarKeepWorkingCount,true);
exg2antt1.EndUpdate();

C# for /COM

axG2antt1.BeginUpdate();
EXG2ANTTLib.Chart var_Chart = axG2antt1.Chart;
	var_Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001");
	var_Chart.LevelCount = 2;
	var_Chart.set_PaneWidth(false,48);
	var_Chart.AllowNonworkingBars = true;
	0var_Chart.Bars.Add("Task:Split").Shortcut = "Task";
axG2antt1.Columns.Add("Tasks");
EXG2ANTTLib.Items var_Items = axG2antt1.Items;
	int h = var_Items.AddItem("Task 1");
	var_Items.set_ItemNonworkingUnits(h,false,"weekday(value) in (0,6)");
	var_Items.AddBar(h,"",Convert.ToDateTime("1/2/2001"),Convert.ToDateTime("1/5/2001"),"A","holyday");
	var_Items.set_ItemBar(h,"A",EXG2ANTTLib.ItemBarPropertyEnum.exBarTreatAsNonworking,true);
	var_Items.AddBar(h,"Task",Convert.ToDateTime("1/5/2001"),Convert.ToDateTime("1/12/2001"),"Z",null);
	var_Items.set_ItemBar(h,"Z",EXG2ANTTLib.ItemBarPropertyEnum.exBarKeepWorkingCount,true);
axG2antt1.EndUpdate();

Delphi

with AxG2antt1 do
begin
	BeginUpdate();
	with Chart do
	begin
		FirstVisibleDate := '1/1/2001';
		LevelCount := 2;
		PaneWidth[False] := 48;
		AllowNonworkingBars := True;
		0Bars.Add('Task:Split').Shortcut := 'Task';
	end;
	Columns.Add('Tasks');
	with Items do
	begin
		h := AddItem('Task 1');
		ItemNonworkingUnits[h,TObject(False)] := 'weekday(value) in (0,6)';
		AddBar(h,'','1/2/2001','1/5/2001','A','holyday');
		ItemBar[h,'A',EXG2ANTTLib.ItemBarPropertyEnum.exBarTreatAsNonworking] := TObject(True);
		AddBar(h,'Task','1/5/2001','1/12/2001','Z',Nil);
		ItemBar[h,'Z',EXG2ANTTLib.ItemBarPropertyEnum.exBarKeepWorkingCount] := TObject(True);
	end;
	EndUpdate();
end

VFP

with thisform.G2antt1
	.BeginUpdate
	with .Chart
		.FirstVisibleDate = {^2001-1-1}
		.LevelCount = 2
		.PaneWidth(.F.) = 48
		.AllowNonworkingBars = .T.
		0.Bars.Add("Task:Split").Shortcut = "Task"
	endwith
	.Columns.Add("Tasks")
	with .Items
		h = .AddItem("Task 1")
		.ItemNonworkingUnits(h,.F.) = "weekday(value) in (0,6)"
		.AddBar(h,"",{^2001-1-2},{^2001-1-5},"A","holyday")
		.ItemBar(h,"A",38) = .T.
		.AddBar(h,"Task",{^2001-1-5},{^2001-1-12},"Z")
		.ItemBar(h,"Z",20) = .T.
	endwith
	.EndUpdate
endwith

 

 

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.