property Bar.Color as Color
Specifies the color of the bar.

 TypeDescription 
   Color A Color expression that indicates the color of the bar. The last 7 bits in the high significant byte of the color indicates the identifier of the skin being used to paint the bar. Use the Add method to add new skins to the control. The skin object is used to draw the bar in the chart area.   
Use the Color property to specify the color to fill the bar. The Color property specifies the color to paint all bars of the same type.  Use the ItemBar(exBarColor) property to specify a different color/skin for a particular bar. Use the Pattern property to specify the brush being used to fill the bar. Use the Shape property to specify the height and the vertical alignment of the middle part of the bar. Use the StartColor property to specify the color for the beginning part of the bar, if the StartShape property is not exShapeIconEmpty. Use the EndColor property to specify the color for the ending part of the bar, if the EndShape property is not exShapeIconEmpty.

In VB.NET or C# you require the following functions until the .NET framework will provide:

You can use the following VB.NET function:
     Shared Function ToUInt32(ByVal c As Color) As UInt32
         Dim i As Long
	 i = c.R
	 i = i + 256 * c.G
	 i = i + 256 * 256 * c.B
	 ToUInt32 = Convert.ToUInt32(i)
     End Function 
You can use the following C# function:
private UInt32 ToUInt32(Color c)
{
	long i;
	i = c.R;
	i = i + 256 * c.G;
	i = i + 256 * 256 * c.B;
	return Convert.ToUInt32(i);
}

The following VB sample creates a new bar called "Task2", that's similar with the "Task" bar excepts that we change the color to fill the bar:

With Gantt1.Chart.Bars
    With .Copy("Task", "Task2")
        .Color = RGB(255, 0, 0)
    End With
End With

The following C++ sample creates a new bar called "Task2", that's similar with the "Task" bar excepts that we change the color to fill the bar:

CBars bars = m_gantt.GetChart().GetBars();
CBar bar = bars.Copy( "Task", "Task2" );
bar.SetColor( RGB(255,0,0) );

The following VB.NET sample creates a new bar called "Task2", that's similar with the "Task" bar excepts that we change the color to fill the bar:

With AxGantt1.Chart.Bars
    With .Copy("Task", "Task2")
        .Color = ToUInt32(Color.Red)
    End With
End With

The following C# sample creates a new bar called "Task2", that's similar with the "Task" bar excepts that we change the color to fill the bar:

EXGANTTLib.Bar bar = axGantt1.Chart.Bars.Copy("Task", "Task2");
bar.Color = ToUInt32(Color.Red);

The following VFP sample creates a new bar called "Task2", that's similar with the "Task" bar excepts that we change the color to fill the bar:

with thisform.Gantt1.Chart.Bars
	with .Copy("Task", "Task2" )
		.Color = RGB(255,0,0)
	endwith
endwith

 


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