C1Schedule - Set Colour of Text in Appointment

Posted by: mwebster on 15 March 2021, 8:26 am EST

    • Post Options:
    • Link

    Posted 15 March 2021, 8:26 am EST - Updated 3 October 2022, 11:20 pm EST

    I am working in VB (Win forms) on an application with C1Schedule and we are displaying a series of appointments in a monthview. I need to be able to set the colour of either the text or the block containing the appointment at runtime. The colour to be used will be passed along from the data table. Some of the entries need to appear normal (black), some need to appear yellow and some need to appear red. The actual needed colour value is stored in the datatable. Please see the attached JPG to see what I am referring to.

  • Posted 15 March 2021, 8:52 am EST

    One more thing…just to clarify. It needs to show this colour on each appointment as soon as the calendar loads and not just when someone clicks on the appointment. I would prefer to change the backcolour of the appointment but the text forecolour would be acceptable as well.

  • Posted 16 March 2021, 4:41 am EST

    Hi,

    You can use the Labels to achieve this, you can assign a label to the appointment and then the appointment will be drawn with the color of the label associated with it. Please refer to the sample attached.

    If you want to custom format each appointment then you can use the BeforeAppointmentFormat event and then assign the back color according to your requirements. If you need further assistance, please let us know.

    Regards.

    Avnish

  • Posted 16 March 2021, 6:40 am EST

    That sounds like what I am looking for but there was no attachment to this thread. If you could please provide it, I would appreciate it.

  • Posted 16 March 2021, 6:44 am EST

    Hi,

    Sorry for the inconvenience, Please find the project attached.

    Regards.

    Avnish

    ScheduleAppColor.zip

  • Posted 16 March 2021, 6:45 am EST

    Thank-you! I will check it out.

  • Posted 16 March 2021, 7:22 am EST

    Ok I took a look at this but I don’t understand how to apply the label. The example does not show how to do that. It just shows a labels table in the database but does not show how to apply that to appointments.

  • Posted 16 March 2021, 7:40 am EST

    I figured out that this uses the “Subject” Field but I am not sure how to go about adding custom labels. Here is the code that I am using to load the appointments onto my C1schedule control:

        Dim ScheduleTable As New DataTable
        Dim JobSchedule As New cJobScheduleList(ConnStr)
        ScheduleTable = JobSchedule.GetMFGSchedule(True)
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName = "ScheduleProperties"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.IndexMapping.MappingName = "JobID"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Subject.MappingName = "Subject"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Start.MappingName = "MFGDate"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.End.MappingName = "MFGDateEnd"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Body.MappingName = "JobNotes"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Location.MappingName = "GeneratedPartDesc"
        C1Schedule1.DataStorage.AppointmentStorage.DataSource = ScheduleTable
        JobSchedule = Nothing
        C1Schedule1.Theme.ShowTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeWeekView = False
        GetDateTotal(Now.date)
    

    I can’t see any way to add the custom labels to the control although I was able to set the subject.

  • Posted 16 March 2021, 7:43 am EST

    Also, I noticed that if I tried to set the Subject to one of the built in labels such as Phone Call, it did not change the colour on the screen.

  • Posted 16 March 2021, 8:31 am EST

    Sorry - another update. I figured out how to get the labels setup but I still can’t figure out how to get the appointments be linked to the labels. here is my revised code:

        Dim LabelTable As New DataTable
        Dim LabelAdapter As New ProductionDataTableAdapters.CalendarLabelsTableAdapter
        LabelAdapter.Connection.ConnectionString = ConnStr
        LabelTable = LabelAdapter.GetData
        LabelAdapter = Nothing
        C1Schedule1.DataStorage.LabelStorage.Mappings.CaptionMapping.MappingName = "LabelCaption"
        C1Schedule1.DataStorage.LabelStorage.Mappings.ColorMapping.MappingName = "LabelColour"
        C1Schedule1.DataStorage.LabelStorage.Mappings.TextMapping.MappingName = "LabelText"
        C1Schedule1.DataStorage.LabelStorage.DataSource = LabelTable
        Dim ScheduleTable As New DataTable
        Dim JobSchedule As New cJobScheduleList(ConnStr)
        ScheduleTable = JobSchedule.GetMFGSchedule(True)
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName = "ScheduleProperties"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.IndexMapping.MappingName = "JobID"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Subject.MappingName = "Subject"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Start.MappingName = "MFGDate"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.End.MappingName = "MFGDateEnd"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Body.MappingName = "JobNotes"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Location.MappingName = "GeneratedPartDesc"
        C1Schedule1.DataStorage.AppointmentStorage.DataSource = ScheduleTable
        JobSchedule = Nothing
        C1Schedule1.Theme.ShowTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeWeekView = False
        GetDateTotal(Now.date)
    
  • Posted 16 March 2021, 9:21 am EST

    Still picking at this. I have tried adding with the GUID of the appropriate label between them to the AppointmentProps XML value and it gives me an error that “g cannot be null” for some strange reason.

    I have figured out everything except how to link the desired label to each appointment.

  • Posted 16 March 2021, 9:23 am EST

    This is the code I am using now:

        Dim LabelTable As New DataTable
        Dim LabelAdapter As New ProductionDataTableAdapters.CalendarLabelsTableAdapter
        LabelAdapter.Connection.ConnectionString = ConnStr
        LabelTable = LabelAdapter.GetData
        LabelAdapter = Nothing
        C1Schedule1.DataStorage.LabelStorage.Mappings.IdMapping.MappingName = "LabelID"
        C1Schedule1.DataStorage.LabelStorage.Mappings.CaptionMapping.MappingName = "LabelCaption"
        C1Schedule1.DataStorage.LabelStorage.Mappings.ColorMapping.MappingName = "LabelColour"
        C1Schedule1.DataStorage.LabelStorage.Mappings.TextMapping.MappingName = "LabelText"
        C1Schedule1.DataStorage.LabelStorage.DataSource = LabelTable
        Dim ScheduleTable As New DataTable
        Dim JobSchedule As New cJobScheduleList(ConnStr)
        ScheduleTable = JobSchedule.GetMFGSchedule(True)
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName = "ScheduleProperties"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.IndexMapping.MappingName = "JobID"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Subject.MappingName = "JobNumber"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Start.MappingName = "MFGDate"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.End.MappingName = "MFGDateEnd"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Body.MappingName = "JobNotes"
        C1Schedule1.DataStorage.AppointmentStorage.Mappings.Location.MappingName = "GeneratedPartDesc"
        C1Schedule1.DataStorage.AppointmentStorage.DataSource = ScheduleTable
        JobSchedule = Nothing
        C1Schedule1.Theme.ShowTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeMonthView = False
        C1Schedule1.Theme.ShowEndTimeWeekView = False
        GetDateTotal(Now.date)
    

    This is the AppointmentProps value that I am using:

    Trueb2b7f184-d071-4e1c-8323-4dc883eb7855

  • Posted 17 March 2021, 7:47 am EST

    Fantastic! Thank-you very much.

  • Posted 17 March 2021, 7:59 am EST

    Hi,

    To set the Label in the AppointmentProps XML, you need to add the label like:

    <AppointmentProps><AllDayEvent>True</AllDayEvent>[b]<Label Id="04cabd78-6edf-4e18-9fe5-439878be6bf0" Index="-1" />[/b]</AppointmentProps>
    

    You just need to replace the guid with the guid of the required label.

    Regards

    Avnish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels