Type | Description | |||
Name as String | A String expression that indicates the name of the bar being created. If the Name parameter includes the ":" or "%"character, it has a special meaning described bellow. |
Return | Description | |||
Bar | A Bar object being inserted. |
The Shortcut property adds a shortcut for the bar, so you can use short names when using the AddBar method . Use the AddBar property to add a new bar to an item. Use the Shape, Pattern and Color properties to define the appearance for the middle part of the bar. Use the StartShape and StartColor properties to define the appearance for the starting part of the bar. Use the EndShape and EndColor properties to define the appearance for the ending part of the bar. The Name property indicates the name of the bar. Use the Copy property to create a clone bar. Use the AllowCreateBar property to specify whether the user can create new bars using the mouse. Use the Height property to specify the height for the bar, if case.
By default, the Bars collection includes the following predefined bars:
The Color property of the Bar object specifies the color being used to paint the bar. This property changes the colors for all bars with the same name. For instance, if you have 3 "Task" bars, and you are changing the color for the "Task" bar, the color is applied to all "Task" bars in the chart. For instance, in order to provide "Task" bars with different colors, you can use the Copy method to copy the Task bar to a new bar, and use the Color to change the color of the bar. The following function generates a Task bar with specified color:
Private Function AddTask(ByVal gantt As EXG2ANTTLibCtl.G2antt, ByVal clr As Long) As String Dim sT As String sT = "Task:" & clr With gantt.Chart.Bars.Copy("Task", sT) .color = clr End With AddTask = sT End Function
The following VB sample adds a custom shape and defines a bar like this :
With G2antt1.Chart.Bars .AddShapeCorner 12345, 1 With .Add("Task2") .Pattern = exPatternDot .Shape = exShapeThinDown .StartShape = 12345 .StartColor = RGB(255, 0, 0) .Color = .StartColor End With End With
The following C++ sample adds a custom shape and defines a bar like above:
CBars bars = m_g2antt.GetChart().GetBars(); bars.AddShapeCorner( COleVariant( (long)12345 ), COleVariant( (long)1 ) ); CBar bar = bars.Add("Task2"); bar.SetPattern( 2 /*exPatternDot*/ ); bar.SetShape( 20 /*exShapeThinDown*/ ); bar.SetStartShape( 12345 ); bar.SetStartColor( RGB(255, 0, 0) ); bar.SetColor( bar.GetStartColor() );
The following VB.NET sample adds a custom shape and defines a bar like above:
With AxG2antt1.Chart.Bars .AddShapeCorner(12345, 1) With .Add("Task2") .Pattern = EXG2ANTTLib.PatternEnum.exPatternDot .Shape = EXG2ANTTLib.ShapeBarEnum.exShapeThinDown .StartShape = 12345 .StartColor = RGB(255, 0, 0) .Color = .StartColor End With End With
The following C# sample adds a custom shape and defines a bar like above:
axG2antt1.Chart.Bars.AddShapeCorner(12345, 1); EXG2ANTTLib.Bar bar = axG2antt1.Chart.Bars.Add("Task2"); bar.Pattern = EXG2ANTTLib.PatternEnum.exPatternDot; bar.Shape = EXG2ANTTLib.ShapeBarEnum.exShapeThinDown; bar.StartShape = (EXG2ANTTLib.ShapeCornerEnum)12345; bar.StartColor = ToUInt32(Color.FromArgb(255, 0, 0)); bar.Color = bar.StartColor;
The following VFP sample adds a custom shape and defines a bar like above:
With thisform.G2antt1.Chart.Bars .AddShapeCorner(12345, 1) With .Add("Task2") .Pattern = 2 && exPatternDot .Shape = 20 && exShapeThinDown .StartShape = 12345 .StartColor = RGB(255, 0, 0) .Color = .StartColor EndWith EndWith