Type | Description | |||
Item as HITEM | A long expression that indicates the the handle of the item where the bar is inserted. | |||
BarName as Variant | A String expression that indicates the name of the bar being inserted, or a long expression that indicates the index of the bar being inserted | |||
DateStart as Variant | A Date expression that indicates the date/time where the bar starts, or a string expression that indicates the start date and time. For instance, the "6/10/2003 10:13", indicates the date and the time. | |||
DateEnd as Variant | A Date expression that indicates the date where the bar ends, or a string expression that indicates the end date and time. For instance, the "6/10/2003 10:13", indicates the date and the time. | |||
Key as Variant | Optional. A String expression that indicates the key of the bar being inserted. If missing, the Key parameter is empty. If the Item has only a single Bar you can not use the Key parameter, else an unique key should be used. | |||
Text as Variant | Optional. A String expression that indicates the text being displayed. The Text may include built-in HTML format. Use the ItemBar(exBarHAlignCaption/exBarVAlignCaption) to display and align the caption of the bar inside or outside of the bar. |
The following VB sample adds a "Milestone" bar and a text beside:
With Gantt1.Items h = .AddItem("new task") .AddBar h, "Milestone", "5/30/2005 10:00", "5/31/2005" .AddBar h, "", "5/31/2005", "6/10/2005", "beside", "<fgcolor=FF0000><b>item</b></fgcolor> to change" End With
or
With Gantt1.Items .AddBar .AddItem("new task"), "Milestone", "5/30/2005 10:00", "6/10/2005", , " <fgcolor=FF0000><b>item</b></fgcolor> to change" End With
The following VB sample adds an item with a single "Task" bar:
Dim h As HITEM, d As Date With Gantt1.Items d = Gantt1.Chart.FirstVisibleDate h = .AddItem("new task") .AddBar h, "Task", Gantt1.Chart.NextDate(d, exDay, 2), Gantt1.Chart.NextDate(d, exDay, 4) End With
The following VB sample adds an item with three bars ( two "Task" bars, and one "Split" bar ) that looks like ):
Dim h As HITEM, d As Date With Gantt1.Items d = Gantt1.Chart.FirstVisibleDate h = .AddItem("new task ") .AddBar h, "Task", d + 2, d + 4, "K1" .AddBar h, "Split", d + 4, d + 5, "K2" .AddBar h, "Task", d + 5, d + 9, "K3" End With
The bar is composed by three parts: K1, K2 and K3.
The following C++ sample adds a "Milestone" bar and a text beside:
#include "Items.h" COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; CItems items = m_gantt.GetItems(); long h = items.AddItem( COleVariant( "new task" ) ); items.AddBar( h, COleVariant("Milestone"), COleVariant( "5/30/2005 10:00" ), COleVariant( "5/31/2005" ), vtMissing, vtMissing ); items.AddBar( h, COleVariant(""), COleVariant( "5/31/2005" ), COleVariant( "6/10/2005" ), COleVariant( _T("just a key") ), COleVariant( "<fgcolor=FF0000><b>item</b></fgcolor> to change" ) );
or
#include "Items.h" COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; CItems items = m_gantt.GetItems(); long h = items.AddItem( COleVariant( "new task" ) ); items.AddBar( h, COleVariant("Milestone"), COleVariant( "5/30/2005 10:00" ), COleVariant( "6/10/2005" ), vtMissing, COleVariant( " <fgcolor=FF0000><b>item</b></fgcolor> to change" ) );
The following C++ sample adds an item with a single "Task" bar:
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; CItems items = m_gantt.GetItems(); CChart chart = m_gantt.GetChart(); DATE d = V2D( &chart.GetFirstVisibleDate() ); long h = items.AddItem( COleVariant("new task") ); items.AddBar( h, COleVariant( "Task"), COleVariant( (double)chart.GetNextDate( d, 4096, COleVariant((long)2) ) ), COleVariant( (double)chart.GetNextDate( d, 4096, COleVariant((long)4) ) ), vtMissing , vtMissing );
The following C++ sample adds an item with three bars ( two "Task" bars, and one "Split" bar ) that looks like above:
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; CItems items = m_gantt.GetItems(); DATE d = V2D( &m_gantt.GetChart().GetFirstVisibleDate() ); long h = items.AddItem( COleVariant("new task") ); items.AddBar( h, COleVariant( "Task"), COleVariant( d + 2 ), COleVariant( d + 4 ), COleVariant( "K1" ), vtMissing ); items.AddBar( h, COleVariant( "Split"), COleVariant( d + 4 ), COleVariant( d + 5 ), COleVariant( "K2" ), vtMissing ); items.AddBar( h, COleVariant( "Task"), COleVariant( d + 5 ), COleVariant( d + 9 ), COleVariant( "K3" ), vtMissing );
where the V2D function converts a Variant expression to a DATE expression and may look like follows:
static DATE V2D( VARIANT* pvtDate ) { COleVariant vtDate; vtDate.ChangeType( VT_DATE, pvtDate ); return V_DATE( &vtDate ); }
The following VB.NET sample adds a "Milestone" bar and a text beside:
With AxGantt1.Items Dim h As Integer = .AddItem("new task") .AddBar(h, "Milestone", "5/30/2005 10:00", "5/31/2005") .AddBar(h, "", "5/31/2005", "6/10/2005", "beside", "<fgcolor=FF0000><b>item</b></fgcolor> to change") End With
or
With AxGantt1.Items Dim h As Integer = .AddItem("new task") .AddBar(h, "Milestone", "5/30/2005 10:00", "6/10/2005", , " <fgcolor=FF0000><b>item</b></fgcolor> to change") End With
The following VB.NET sample adds an item with a single "Task" bar:
With AxGantt1.Items Dim d As DateTime = AxGantt1.Chart.FirstVisibleDate Dim h As Integer = .AddItem("new task") .AddBar(h, "Task", AxGantt1.Chart.NextDate(d, EXGANTTLib.UnitEnum.exDay, 2), AxGantt1.Chart.NextDate(d, EXGANTTLib.UnitEnum.exDay, 4)) End With
The following VB.NET sample adds an item with three bars ( two "Task" bars, and one "Split" bar ) that looks like above:
With AxGantt1.Items Dim d As DateTime = AxGantt1.Chart.FirstVisibleDate Dim h As Integer = .AddItem("new task ") .AddBar(h, "Task", d.AddDays(2), d.AddDays(4), "K1") .AddBar(h, "Split", d.AddDays(4), d.AddDays(5), "K2") .AddBar(h, "Task", d.AddDays(5), d.AddDays(9), "K3") End With
The following C# sample adds a "Milestone" bar and a text beside:
EXGANTTLib.Items items = axGantt1.Items; int h = items.AddItem("new task"); items.AddBar(h, "Milestone", "5/30/2005 10:00", "5/31/2005", null, null); items.AddBar(h, "", "5/31/2005", "6/10/2005", "just a new key", "<fgcolor=FF0000><b>item</b></fgcolor> to change");
or
EXGANTTLib.Items items = axGantt1.Items; int h = items.AddItem("new task"); items.AddBar(h, "Milestone", "5/30/2005 10:00", "6/10/2005", null, " <fgcolor=FF0000><b>item</b></fgcolor> to change");
The following C# sample adds an item with a single "Task" bar:
EXGANTTLib.Items items = axGantt1.Items; int h = items.AddItem("new task"); DateTime d = Convert.ToDateTime(axGantt1.Chart.FirstVisibleDate); items.AddBar(h, "Task", axGantt1.Chart.get_NextDate(d, EXGANTTLib.UnitEnum.exDay, 2), axGantt1.Chart.get_NextDate(d, EXGANTTLib.UnitEnum.exDay, 4), null, null);
The following C# sample adds an item with three bars ( two "Task" bars, and one "Split" bar ) that looks like above:
EXGANTTLib.Items items = axGantt1.Items; int h = items.AddItem("new task"); DateTime d = Convert.ToDateTime( axGantt1.Chart.FirstVisibleDate ); items.AddBar(h, "Task", d.AddDays(2), d.AddDays(4), "K1", null ); items.AddBar(h, "Split", d.AddDays(4), d.AddDays(5), "K2", null); items.AddBar(h, "Task", d.AddDays(5), d.AddDays(9), "K3", null);
The following VFP sample adds an item with a single "Task" bar:
With thisform.Gantt1.Items d = thisform.Gantt1.Chart.FirstVisibleDate .DefaultItem = .AddItem("new task") .AddBar(0, "Task", thisform.Gantt1.Chart.NextDate(d,4096,2), thisform.Gantt1.Chart.NextDate(d,4096,4)) EndWith
The following VFP sample adds an item with three bars ( two "Task" bars, and one "Split" bar ) that looks like above:
With thisform.Gantt1.Items thisform.Gantt1.Chart.FirstVisibleDate = "5/29/2005" .DefaultItem = .AddItem("new task") .AddBar(0, "Task", "5/31/2005", "6/2/2005", "K1", "") .AddBar(0, "Split", "6/2/2005", "6/4/2005", "K2", "") .AddBar(0, "Task", "6/4/2005", "6/9/2005", "K3", "") EndWith