ComponentOne GanttView for WinForms
Showing the Duration Columns in the Grid
GanttView for WinForms Task-Based Help > Showing the Duration Columns in the Grid

This topic shows how to programmatically show/hide the values of the Duration and DurationUnits properties in the grid.

To write code in Visual Basic

Visual Basic
Copy Code
Private Sub chkShowDuration_CheckedChanged(sender As Object, e As EventArgs)
       Dim durationCol As TaskPropertyColumn = ganttView.Columns.Search(TaskProperty.Duration)
       Dim unitsCol As TaskPropertyColumn = ganttView.Columns.Search(TaskProperty.DurationUnits)
       If durationCol IsNot Nothing AndAlso unitsCol IsNot Nothing Then
              Dim visible As Boolean = chkShowDuration.Checked
              durationCol.Visible = visible
              unitsCol.Visible = visible
       End If
End Sub

To write code in C#

C#
Copy Code
private void chkShowDuration_CheckedChanged(object sender, EventArgs e)
{
    TaskPropertyColumn durationCol = ganttView.Columns.Search(TaskProperty.Duration);
    TaskPropertyColumn unitsCol = ganttView.Columns.Search(TaskProperty.DurationUnits);
    if (durationCol != null && unitsCol != null)
    {
        bool visible = chkShowDuration.Checked;
        durationCol.Visible = visible;
        unitsCol.Visible = visible;
    }
}
See Also