method Chart.AddNonworkingDate (Date as Variant)
Adds a nonworking date.

TypeDescription
Date as Variant A Date expression that indicates the date being marked as nonworking day.
Use the AddNonworkingDate method to add custom dates as nonworking days. Use the NonworkingDays property to mark days in a week as being as nonworking. Use the ShowNonworkingDates property to show or hide the nonworking dates in the control's chart area. Use the RemoveNonworkingDate method to remove a specified date from the nonworking dates collection. The RemoveNonworkingDate method removes only a date previously added using the AddNonworkingDate method. Use the ClearNonworkingDates method to remove all nonworking dates. Use the NonworkingDaysPattern property to specify the pattern being used to fill non-working days. The NonworkingDaysColor property specifies the color being used to fill the non-working days. Use the DateChange event to notify whether the user browses a new date in the chart area. Use the IsNonworkingDate property to retrieve a value that indicates whether a date is marked as nonworking day. Use the Add("A:B") to add a bar that displays the bar A in the working area, and B in non-working areas.

 

The following VB sample marks the 11th of each month as nonworking day ( the code enumerates the visible dates, and marks one by one, if case ):

Private Sub Gantt1_DateChange()
    With Gantt1
        .BeginUpdate
        With .Chart
            Dim d As Date
            d = .FirstVisibleDate
            Do While .IsDateVisible(d)
                If Day(d) = 11 Then
                    If Not (.IsNonworkingDate(d)) Then
                        .AddNonworkingDate d
                    End If
                End If
                d = .NextDate(d, exDay, 1)
            Loop
        End With
        .EndUpdate
    End With
End Sub

The following VB.NET sample marks the 11th of each month as nonworking day:

Private Sub AxGantt1_DateChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxGantt1.DateChange
    With AxGantt1
        .BeginUpdate()
        With .Chart
            Dim d As Date = .FirstVisibleDate
            Do While .IsDateVisible(d)
                If d.Day = 11 Then
                    If Not (.IsNonworkingDate(d)) Then
                        .AddNonworkingDate(d)
                    End If
                End If
                d = .NextDate(d, EXGANTTLib.UnitEnum.exDay, 1)
            Loop
        End With
        .EndUpdate()
    End With
End Sub

The following C# sample marks the 11th of each month as nonworking day:

private void axGantt1_DateChange(object sender, EventArgs e)
{
	axGantt1.BeginUpdate();
	EXGANTTLib.Chart chart = axGantt1.Chart;
	DateTime d = Convert.ToDateTime(chart.FirstVisibleDate);
	while ( chart.get_IsDateVisible(d) )
	{
		if ( d.Day == 11 )
			if ( !chart.get_IsNonworkingDate( d ) )
				chart.AddNonworkingDate(d);
		d = chart.get_NextDate(d, EXGANTTLib.UnitEnum.exDay, 1);
	}
	axGantt1.EndUpdate();
}
}

The following VFP sample marks the 11th of each month as nonworking day ( DateChange event ):

*** ActiveX Control Event ***

With thisform.Gantt1
    .BeginUpdate
    With .Chart
        local d
        d = .FirstVisibleDate
        Do While .IsDateVisible(d)
            If Day(d) = 11 Then
                If Not (.IsNonworkingDate(d)) Then
                    .AddNonworkingDate(d)
                EndIf
            EndIf
            d = .NextDate(d, 4096, 1)
        enddo
    EndWith
    .EndUpdate
EndWith