Hi All,
Sorry to bother you again, got another Gantt question, which I thought would be easy, however it is turning out to be not so.
I have set a MaxRange on the gantt chart. That works fine in that it won't set any tasks beyond that date but what I can't do disabled appearance for the dates after the max range to make it obvious to a user they cannot put any dates there. I would have thought it would do that by default.
I looked for an easy way to do this, but A) there appears to be no property settings for "DatesAfterMaxRange.Appearance" or B) No calendar.Initilize column event that I can use to set the appearance (The header init does not cut it).
If there is something I have not found to do this, then please let me know.
I tried to work around this by using a creation filter which don't seem to do anything (though I know through stepping into the code, that it does hit the change colour line) see below:
Imports Infragistics.Win
Imports Infragistics.Win.Misc
Imports Infragistics.Win.UltraWinGanttView
Imports Infragistics.Win.UltraWinSchedule.TimelineView
Imports Infragistics.Win.UltraWinGanttView.UIElements
Public Class TimelineCreationFilter : Implements IUIElementCreationFilter
Private appearance As AppearanceBase = Nothing
Public Sub AfterCreateChildElements(parent As UIElement) Implements IUIElementCreationFilter.AfterCreateChildElements
'Keep going until the parent is a Task Area UI Element.
If TypeOf (parent) Is TaskAreaUIElement Then
Dim TaskAreaElement As TaskAreaUIElement
Dim TimeSlotElement As TimeSlotUIElement
TaskAreaElement = parent
'Get the time slot element
TimeSlotElement = TaskAreaElement.GetDescendant(GetType(TimeSlotUIElement), gstartdate.AddMonths(gsettings.getSetting("MonthRange")))
If IsNothing(TimeSlotElement) = False Then
If IsNothing(Me.appearance) = True Then
Me.appearance = New Infragistics.Win.Appearance()
End If
'Colour it grey to show it is outside of the max range.
Me.appearance.BackColor = Color.Silver
Me.appearance.BorderColor = Color.Black
End Sub
Public Function BeforeCreateChildElements(parent As UIElement) As Boolean Implements IUIElementCreationFilter.BeforeCreateChildElements
Return False
End Function
That has sorted it, thanks for taking the time to look at this.
Alex
Hello Alex,
Thank you for your sample project. As it turns out, you were importing the wrong namespace in GanttViewDrawFilter.vb. You need to import Infragistics.Win.UltraWinSchedule.TimelineView, not DayView. Once you make that change, you will see that the DrawFilter works correctly.
Hi Dave,
Sorry it has takien me so long to get back to you, I have had to leave this for a bit while I got on with other more critical things.
It seems that the problem lies with the "If (TypeOf (drawParams.Element) Is TimeSlotUIElement) Then" , as this is never true in GetPhasesToFilter event.
I have created stripped down sample project for you to look based on my main project at with this problem, as my main project is far too complicated.
Thank you for your response. The line of code you posted should work. If you can ZIP up and attach the project using the DrawFilter, I'll be more than willing to look at it to see if you're missing anything.
Thanks for the sample, however I still cannot get it to work, unlike the creation filter I posted earlier the code inside the draw filter (other than the contstructor) is never hit.
I am assigning the draw filter on form load using:
ugvOffering.DrawFilter = New GanttViewDrawFilter(ugvOffering.CalendarInfo)
Is there a redraw function I need to call to trigger it? Refresh does not seem to.
Thanks,