New to Telerik UI for WinForms? Start a free 30-day trial
TextView Item Formatting
Updated over 6 months ago
RadGanttView offers two events for formatting the text view part. The TextViewItemFormatting event is fired for each item (row) and the TextViewCellFormatting is fired for every cell.
Here is an example demonstrating how to use the event to make all summary items have a green back color and all tasks a yellow one.
C#
private void radGanttView1_TextViewItemFormatting(object sender, GanttViewTextViewItemFormattingEventArgs e)
{
if (e.Item.Items.Count > 0)
{
e.ItemElement.DrawFill = true;
e.ItemElement.BackColor = Color.LightGreen;
e.ItemElement.GradientStyle = GradientStyles.Solid;
}
else if (e.Item.Start != e.Item.End)
{
e.ItemElement.DrawFill = true;
e.ItemElement.BackColor = Color.Yellow;
e.ItemElement.GradientStyle = GradientStyles.Solid;
}
else
{
e.ItemElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
e.ItemElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.ItemElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
}
}

Another example showing how to change the fore color of the cells in the Title column for all types of tasks that start on an even day of the month.
C#
private void radGanttView1_TextViewCellFormatting(object sender, GanttViewTextViewCellFormattingEventArgs e)
{
if (e.Item.Start.Day % 2 == 0 && e.Column.Name == "Title")
{
e.CellElement.ForeColor = Color.Red;
}
else
{
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}
}
