| GanttView for WinForms Task-Based Help > Customizing the Bar Style |
To call attention to task bars on a Gantt view, such as a milestone, you can change their color, shape, or pattern to separate them from other bars of a particular type.
You could customize the appearance of all the bar styles or you could customize the appearance of an individual Gantt bar if you want to highlight a specific task in your plan.
To change the bar style for all manual tasks programmatically, complete the following:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub btnChangeBarStyle_Click(sender As Object, e As EventArgs)
Dim bs As BarStyle = ganttView.GetPredefinedBarStyle(BarType.ManualTask)
bs.BarColor = Color.LightCoral
ganttView.BarStyles.Add(bs)
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void btnChangeBarStyle_Click(object sender, EventArgs e)
{
BarStyle bs = ganttView.GetPredefinedBarStyle(BarType.ManualTask);
bs.BarColor = Color.LightCoral;
ganttView.BarStyles.Add(bs);
}
|
|
To change bar style for task3 programmatically, complete the following:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub btnChangeTaskStyle_Click(sender As Object, e As EventArgs)
Dim task3 As Task = ganttView.Tasks.Search("Task 3")
If task3 IsNot Nothing Then
Dim bs As BarStyle = ganttView.GetPredefinedBarStyle(BarType.ManualTask)
bs.BarColor = Color.Green
bs.BarShape = BarShape.MiddleBar
bs.StartShape = 19
bs.EndShape = 19
task3.BarStyles.Add(bs)
End If
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void btnChangeTaskStyle_Click(object sender, EventArgs e)
{
Task task3 = ganttView.Tasks.Search("Task 3");
if (task3 != null)
{
BarStyle bs = ganttView.GetPredefinedBarStyle(BarType.ManualTask);
bs.BarColor = Color.Green;
bs.BarShape = BarShape.MiddleBar;
bs.StartShape = 19;
bs.EndShape = 19;
task3.BarStyles.Add(bs);
}
}
|
|