I've used this wonderful tutorial/sample to be able to show baselines for my tasks. Everything works as expected, and I am able to produce a nice representation of both my current timelines as well as my baselines. The problem I do run into is when I select any of the baseline representations. When I do, I get this unhandled exception:
For what it's worth, I have disabled all drag actions as they are not necessary for this project. I don't even need the ability to select a task by clicking on the timeline; however, I have not been able to identify a method for disabling this nor handling the error before it reaches an unhandled exception.
Would someone be able to provide me with a method of either disabling this or handling the error?
For another very minor question - is there a way I can force the rectangle for the baseline to go behind the task that the baseline is defined for? I'm assuming its a draw order, but honestly graphics are not my strong suit and I'm struggling with this.
Thanks!
Sorry I forgot to include the link to the sample I used...
http://ko.infragistics.com/community/forums/t/63942.aspx
Another thing... when I have a baseline bar that starts or finishes beyond the timeline bar for that task, I can no longer calculate it's position. Is there a way I can find the X position based on the timeline's timeslots and then Y position from the task's position in the grid?
OK - I got the answer to my last question, so I just thought I would share.
Understandably, there does not exist a TaskUIElement for items that have no visual representation in the Timeline section of the Gantt. Rather than look for the TaskUIElement, I grabbed the TaskAreaUIElement. Once acquired, I reviewed all the RowUIElements in the Ultragrid section of the Ultraganttview, and added a TaskUIElement for those with Baselines. I referenced the TimeSlotUIElement to position in the X and the RowUIElement to position in the Y. This approach is working very smoothly.
I'm still struggling with handling the click event of a task.
HI Mictherr,
My apologies to ask via a reply to this thread but you seem to have solved an issue i am struggling with.
I am unable to accurately place a task on a timeline as i cannot accurately work out what the X axis should be. For a day interval it is fine but when it is a week or month i am struggling so wondered if you were able to assist in what you have already done?
Many thanks in advance
regards
Simon
No problem :) First of all, I should say that even when I show my schedule by week or month, I still maintian my primary interval as days. I find if I don't do that, my bar representation isn't accurate. I utilize the header initialization event to essentially make the divisions of the primary interval not visible.
I've also modified my coding of the overlay significantly from the original sample because I felt this better suited my application.
So that in mind, this is what I have done. If you were to have the primary interval at anything else, you would have to adjust bolded width in the statements below by performing some logic such as dividing by the number of days in the week or in the month:
Dim El as TaskAreaUIElement=TryCast(parent, TaskAreaUIElement)
Dim e2 as TimeSlotUIElement
Dim ug as UltraGrid
ug = DirectCast(Me.UltraGanttView1.[GetType]().GetField("grid", System.Reflection.BindingFlags.CreateInstance Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic).GetValue(Me.UltraGanttView1), UltraGrid)
If El IsNot Nothing AndAlso El.[GetType]()=GetType(TaskAreaUIElement) Then
e2=BaselineExecutionSchedule.UltraGanttView1.UIElement.GetDescendent(GetType(TimeSlotUIElement))
For each ugrow in BaselineExecutionSchedule.ug.rows
If ugrows.cells("BaselineStart1").value.tostring<>String.Empty And ugrow.cells("BaselineEnd1").Value.ToString<>String.Empty then
Dim item as New Task
Dim basestart as DateTime=Cdate(ugrow.cells("BaselineStart1").Value
Dim basend as DateTime=Cdate(ugrow.cells("BaselineEnd1").Value
Dim ts as TimeSpan=basestart=e2.DateTimeRange.StartDateTime
item.StartDateTime=basestart
item.Duration=baseend-basestart
item.Name="Baseline 1"
item.Tag=ugrow.cells("RowNumber")
item.TaskSettings.Enabled=DefaultableBoolean.False
Dim tb as New TaskUIElement(El, item)
tb.Rect = New Rectangle(e2.Rect.X + (ts.Days) * e2.Rect.Width, ugrow.GetUIElement.Rect.Y + 10, (item.Duration.Days + 1) * e2.Rect.Width, 10
El.ChildElements.Add(tb)
End If
Next
I hope this is of some help to you! I know you we are told not to try to access the UltraGrid of the UltraGanttView, but I believe since we are not manipulating it and only gaining information it should be fine. It works perfectly for me.
Many thanks for this,
It is indeed at the interval levels other than day that I am struggling to get a specific placement of the bar - i have adopted a method which takes the days in the month and calculates this against the with of a TimeSlotUIElement and this way i get a rough idea of where a day would be, but it is not accurate or consistent!
So I was interested when yo said that you leave your interval as day but still show as week or month. How do you achieve that?
Many thanks
Sorry for the delay!
So I always make sure that my primary interval is in the form of a day. I set the width of the primary interval to different sizes depending on what interval I am truly looking at. For instance, if I am looking at the week interval as my base, I set the primary interval column width to 10. Month is 4, and Year is 2. When I actually truly want the day as the base, then I set it to 0. I've found these values have served me really well.
The following is a snapshot of it set to week:
Now in the TimelineColumnHeaderInitializing event, I set the following so that the text doesn't display for the primary interval:
If e.DateTimeInterval.IsPrimaryInterval = True Then
e.Text = String.Empty
Hope that helps!