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
1187
On show appointment subject on day view
posted

We are using the dayview control and we have appointments that show the start and end times on this view.  I would only like the subject to show on the dayview appointments.  How can I change this?

Parents
No Data
Reply
  • 2094
    Offline posted

    You will have to use a Custom CreationFilter

    Hope this help.

    Cheers
    Aaron

     

    Here you go.

    On the form that has the DayView Control.....

    • Delcare the object in the Form
      Private CustomCreationFilter As New CustomAppointmentTextCreationFilter(Me.dayViewAppointments, AppointmentTextDisplayStyle.Automatic)
    • Assign the Creation Filter in the Form Load Event
      Me.dayViewAppointments.CreationFilter = CustomCreationFilter

    Dump this in its own class

    Imports Infragistics.Win
    Imports Infragistics.Win.UltraWinSchedule
    Imports Infragistics.Win.UltraWinSchedule.DayView
    Imports System.Globalization
    Imports System.Text

    ' Users of Infragistics controls normally don't need an understanding of how UIElements are implemented and most
    ' often have no need for using a UIElement creation filter. This advanced extensibility mechanism is exposed for
    ' developers who want to modify, add to and/or replace the UIElements of a control.
    '
    ' All controls that are based on the Presentation Layer Framework expose a UIElement creation/positioning 
    ' extensibility mechanism.  To customize the size and/or location of UIElements or to add or replace one or more
    ' UIElements of a control you need to implement the IUIElementCreationFilter interface on an object and set the
    ' CreationFilter property of the control to that object at runtime.
    '
    ' This Creation Filter allows you to have multiple images displayed for a single Appointment when using
    ' the UltraDayView. Note, when using this Creation Filter it is advised that you do NOT assign the Appointment
    ' an Image through the conventional means (i.e. myAppointment.Appearance.Image = someImage)
    '

    #Region " CustomAppointmentTextCreationFilter"

    Public Class CustomAppointmentTextCreationFilter
        Implements IUIElementCreationFilter

    #Region "Member variables"
        Private ultraDayView As UltraDayView = Nothing
        Private _displayStyle As AppointmentTextDisplayStyle

    #End Region

    #Region "Constructor"
        Public Sub New(ByVal ultraDayView As UltraDayView, ByVal displayStyle As AppointmentTextDisplayStyle)

            MyBase.New()

            Me.ultraDayView = ultraDayView
            Me._displayStyle = displayStyle

        End Sub
    #End Region

    #Region "DisplayStyle Property"

        ' <summary>
        ' Gets/sets the display style for appointment text. Note that
        ' the AppointmentTextDisplayStyle enumeration is a set of bitflags,
        ' so that any combination of the individual constants can be specified.
        ' For example, to specify that an Appointment should display the Subject
        ' and the start and end times, set the property like so: <br></br>
        ' DisplayStyle = AppointmentTextDisplayStyle.Subject | AppointmentTextDisplayStyle.Time;
        ' </summary>
        Public Property DisplayStyle() As AppointmentTextDisplayStyle
            Get
                Return Me._displayStyle
            End Get
            Set(ByVal Value As AppointmentTextDisplayStyle)
                If Value <> Me._displayStyle Then
                    Me._displayStyle = Value
                    If Not Me.ultraDayView Is Nothing Then
                        Me.ultraDayView.UIElement.DirtyChildElements(True)
                    End If
                End If
            End Set
        End Property
    #End Region

    #Region "GetAppointmentText"

        Public Function GetAppointmentText(ByVal appointment As Appointment) As String

            Select Case Me.DisplayStyle
                Case AppointmentTextDisplayStyle.Automatic
                    Return Nothing
                Case AppointmentTextDisplayStyle.SubjectOnly
                    GetAppointmentText = appointment.Subject
                Case Else
                    GetAppointmentText = "Do More states here"
            End Select

        End Function

    #End Region

    #Region "IUIElementCreationFilter implementation"

        Public Sub AfterCreateChildElements(ByVal parent As UIElement) Implements IUIElementCreationFilter.AfterCreateChildElements
            '  If the parent is an EmbeddableUIElementBase, get the associated AppointmentUIElement
            '  and remove all elements except for the EmbeddableUIElementBase, and change the bounds
            '  of the EmbeddableUIElementBase to occupy the entire bounds of the AppointmentUIElement.
            Dim embeddableElement As EmbeddableUIElementBase = TryCast(parent, EmbeddableUIElementBase)
            Dim appointmentElement As AppointmentUIElement
            If embeddableElement IsNot Nothing Then
                appointmentElement = TryCast(embeddableElement.GetAncestor(GetType(AppointmentUIElement)), AppointmentUIElement)
            Else
                appointmentElement = Nothing
            End If

            If appointmentElement IsNot Nothing Then
                '  Get the associated appointment, and the text that should be displayed for it.
                Dim appointment As Appointment = TryCast(appointmentElement.GetContext(GetType(Appointment)), Appointment)
                Dim text As String = Me.GetAppointmentText(appointment)
                'Leave text as Automatic
                If text = Nothing Then Exit Sub

                '  Set the bounds of the embeddable element
                embeddableElement.Rect = appointmentElement.RectInsideBorders

                '  Get the embeddable element's TextUIElement
                Dim textElement As TextUIElement = TryCast(embeddableElement.GetDescendant(GetType(TextUIElement)), TextUIElement)

                If textElement IsNot Nothing Then
                    '  Change the text displayed by the embeddable element based on
                    '  the DisplayStyle.
                    textElement.Text = text

                    '  Reverse iterate the AppointmentUIElement's ChildElements collection
                    '  and remove all elements except for the EmbeddableUIElementBase
                    Dim childElements As UIElementsCollection = appointmentElement.ChildElements
                    Dim childElementCount As Integer = childElements.Count
                    Dim i As Integer = childElementCount - 1
                    For i = i To 0 Step -1

                        Dim element As UIElement = childElements(i)
                        If element Is embeddableElement Then
                            Continue For
                        End If

                        childElements.Remove(element)
                    Next
                End If
            End If

        End Sub

        Public Function BeforeCreateChildElements(ByVal parent As UIElement) As Boolean Implements IUIElementCreationFilter.BeforeCreateChildElements
            '   We aren't using this method, so return false.
            Return False
        End Function

    #End Region

    End Class



    #Region " AppointmentTextDisplayStyle Enum"

    ' <summary>
    ' Enumeration which describes how the text will be displayed
    ' for appointments in the UltraDayView control.
    ' </summary>
    <Flags()> _
    Public Enum AppointmentTextDisplayStyle

        ' <summary>
        ' The UltraDayView displays appointment text as it does by default;
        ' the subject is always displayed, the start and end times are displayed
        ' when they do not coincide exactly with the TimeSlots they span, and
        ' the Description is displayed when it fits in the available space.
        ' </summary>
        Automatic = 0

        ' <summary>
        ' The value of the Appointment's Subject property is displayed.
        ' </summary>
        SubjectOnly = 1

    End Enum
    #End Region

Children
No Data