Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4018
BarColor In WeekView and MonthViewSingle
posted

I know that the BarColor property of the appointment object does not exist in the WeekView or the MonthViewSingle.  I have added a creation filter to the week and month views to try to simulate the BarColor that exists in the day view  I also am adding a couple of buttons to the appointment as well.  This code is working, however I seem to be running into some sort of screen refresh problem.  Once I change a view from week to month, my buttons appear properly, but my colored rectangle disappears.  If I move the mouse around, the colors magically appear.

I know this is a refresh problem, but I have put refreshes all over my code to no avail.  What's curious is that the buttons display properly all the time.  It's just the colored rectangle that disappears.  Of course, I'd love to see the BarColor property built directly into the Week and Month views, but until then I am happy with this work-around.  Here is my code that adds the colored rectangle.  I've also attached a screen cap.

Private Sub AddBarColorUIElement(ByRef objUIElement As UIElement, ByRef objAppointment As Appointment, ByVal objWeekView As UltraWeekView, ByVal objColor As Color)

 

 

 

'this sub adds a UIElement to the CreationFilter...

If Not IsNothing(objColor) Then

 

 

 

 

'create an instance of E2WeekViewUIElement to place a button in the appointment...

Dim objNewWeekViewUIElement As New E2WeekViewUIElementobjUIElement.Parent)

objNewWeekViewUIElement.Appointment = objAppointment

objNewWeekViewUIElement.WeekView = objWeekView

 

 

 

 

'IMPORTANT! position the custom UIElement using its Rect property...

objNewWeekViewUIElement.Rect = New Rectangle(objUIElement.RectInsideBorders.X, objUIElement.RectInsideBorders.Y, intBarColorWidth, objUIElement.RectInsideBorders.Height)

 

 

If Not IsNothing(objColor) Then

 

 

 

 

'fill the rectangle with the barcolor of the appointment...

Dim gr As Graphics = objWeekView.CreateGraphics

 

 

 

 

Dim SolidBrush As New SolidBrush(objColor)

gr.FillRectangle(SolidBrush, objNewWeekViewUIElement.Rect)

 

 

End If

 

 

 

'add the custom UIElement to its parent's ChildElements collection...

objUIElement.Parent.ChildElements.Add(objNewWeekViewUIElement)

 

 

End If

 

End Sub