ComponentOne GanttView for WPF
Custom Bar Styles
Features > Style and Appearance > Custom Bar Styles

In GanttView, all the tasks in a project plan are represented through task bars, which depict attributes like start and finish date, duration, percent complete, current status, etc. The visual appeal of these bars can be enhanced by customizing their color, shape, and hatch style.

This is possible in GanttView through the BarStyle class, which includes various properties to set the background color, shape and hatch style of task bars. Task bars can also be customized at runtime through the Bar Styles dialog, which can be accessed by clicking the Bar Styles button available on the toolbar. In addition, the control lets you adjust the height of the task bar according to the font applied to GanttView.  The C1GanttView class provides the AdaptiveBarHeight property, which if set to true automatically adjusts the height of the task bar according to GanttView's font size. You can also set the bar height explicitly by setting the AdaptiveBarHeight property to false and then setting the height using the BarHeight property.

The following image shows a GanttView with customized task bars.

Customizing bar styles

Properties available in the BarStyle class for customizing the task bars are as follows:

Property Purpose
BarType To specify the bar(s) on which the customization is to be applied.
BarColor To set the background color of the task bar.
BarShape To set the shape of the task bar.
BarPattern To set the hatch style for filling the task bar.
EndPattern To set the hatch style for filling the shape at the end of the task bar.

The following code illustrates how to customize task bars. This example uses the sample created in the Quick Start.

'Creating an instance of bar style
Dim bs As New BarStyle()

'Applying customization to manual tasks only
bs.BarType = BarType.ManualTask
bs.BarColor = Colors.LightGreen
bs.BarShape = BarShape.Frame
bs.BarPattern = HatchPattern.Gradient
bs.EndPattern = HatchPattern.Empty

'Adding the bar style object to gantt view 
gv.BarStyles.Add(bs)
//Creating an instance of bar style
BarStyle bs = new BarStyle();

//Applying customization to manual tasks only
bs.BarType = BarType.ManualTask;
bs.BarColor = Colors.LightGreen;
bs.BarShape = BarShape.Frame;
bs.BarPattern = HatchPattern.Gradient;
bs.EndPattern = HatchPattern.Empty;

//Adding the bar style object to gantt view 
gv.BarStyles.Add(bs);
See Also