I have a calendar-centric application that uses the UltraCalendarInfo component in conjunction with UltraDayView, UltraWeekView, UltraMonthViewSingle and UltraTimelineView controls. Users have the ability to customize the labels of Calendar Appointments as displayed within the Subject property by specifying which properties of my underlying domain object that they wish to display (e.g. Appointment No., Site Name, Job Priority, etc), and can include Newline characters between these domain object properties should they so desire. The effect of this is that the Subject text can thus be displayed over multiple lines.
The problem I am having is that displaying the subject over multiple lines is fine which working in the UltraDayView control, but in the UltraTimelineView only the first line is actually visible. Now obviously I don't what to remove the newline characters for the Appointment.Subject property as that will effect all calendar views but I am cannot find a way to omit them for the UltraTimelineView only. I have looked at great detail on how this could be done using either or a DrawFilter or a CreationFilter without any success.
In the case of the DrawFilter I thought that perhaps handling the BeforeDrawChildElements DrawPhase of the Appointment would be the best way to go, but it (shown below) did not work. Can anybody provide me with some clues as to the best way to attempt this? Thanks.
Private Function HandleDrawPhaseBeforeDrawChildElements(ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean Dim result As Boolean = False Try If Not drawParams.DrawPhase = DrawPhase.BeforeDrawChildElements Then Exit Function If TypeOf drawParams.Element Is TimelineView.AppointmentUIElement Then Dim textElement As UIElement = drawParams.Element.GetDescendant(GetType(EditorWithTextDisplayTextUIElement)) If textElement IsNot Nothing Then Dim textUIElement As EditorWithTextDisplayTextUIElement = CType(textElement, EditorWithTextDisplayTextUIElement) If textUIElement.Text.Contains(Environment.NewLine) Then textUIElement.Text = textUIElement.Text.Replace(Environment.NewLine, " ") End If End If End If Catch ex As Exception ' Do something? End Try Return resultEnd Function
Hello Mark,
In order to remove the NewLine characters from the Appointment Subject you could use either the DrawFilter or the CreationFilter as you have already found out. Drawfilter give us the opportunity to draw the TextUIElement of the Appointment by using the DrawString method from the Graphics class.
You can find more information about DrawFilter and DrawString method here:
http://help.infragistics.com/Help/Doc/WinForms/2012.2/CLR4.0/HTML/Win_Draw_Filter.html
http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/HTML/Infragistics2.Win.v11.2~Infragistics.Win.DrawUtility~DrawString.html
I’ve implemented this suggestion in a simple sample, and you could run and evaluate it, please see attached zip.
Please let me know if you have any further questions.
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue?
Thank you for using Infragistics Components.
Thank you - that is the solution that I was looking for. I guess the important fact is that you can't modify the Text property of the TextUIElement, you just need to handle the drawing of the edited text yourself.