• Changing the background color of the rows in the Schedule [Janus GridEX WinForms Control v3.5 for .NET]

    This tutorial is intended to show how to change the background color of the rows in the Schedule control using the WorkingHourSchema object





    The following code shows how to format the rows based on the day of the week





    In VB:



    'Create a new ScheduleHourRange object to specify the format style settings and the

    'time and days when the format style will be applied

    Dim hourRange As New ScheduleHourRange()



    'Specify the start and end time that you want to format

    hourRange.EndTime = New TimeSpan(10, 0, 0)

    hourRange.StartTime = New TimeSpan(8, 0, 0)



    'Specify the days of the week that you want to format

    hourRange.DayOfWeek = ScheduleDayOfWeek.Monday Or ScheduleDayOfWeek.Tuesday Or _

    ScheduleDayOfWeek.Wednesday Or ScheduleDayOfWeek.Thursday Or ScheduleDayOfWeek.Friday



    'Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red



    'Add the ScheduleHourRange to the WorkingHoursRange collection of the WorkingHourSchema

    Me.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange)







    In C#



    //Create a new ScheduleHourRange object to specify the format style settings and the

    //time and days when the format style will be applied

    ScheduleHourRange hourRange = new ScheduleHourRange();



    //Specify the start and end time that you want to format

    hourRange.EndTime = new TimeSpan(10, 0, 0);

    hourRange.StartTime = new TimeSpan(8, 0, 0);



    //Specify the days of the week that you want to format

    hourRange.DayOfWeek = ScheduleDayOfWeek.Monday | ScheduleDayOfWeek.Thursday | ScheduleDayOfWeek.Wednesday | ScheduleDayOfWeek.Thursday | ScheduleDayOfWeek.Friday;



    //Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red;



    //Add the ScheduleHourRange to the WorkingHoursRange collection of the WorkingHourSchema

    this.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange);









    The following code shows how to use the Exceptions collection to format the rows for a specific Date



    In VB:



    'Create a new WorkingHourException

    Dim exception As New WorkingHourException()



    'Specify the date range where you want to give the format

    'Note: The date range must be of at least one day, and use the StartTime and EndTime 'properties of the HourRange to set the time of the day where the format will be applied

    exception.DateRange = New DateRange(New DateTime(2006, 1, 15), New DateTime(2006, 1, 16))



    'Specify the start and end time that you want to format exception.HourRange.EndTime = New TimeSpan(14, 0, 0)

    exception.HourRange.StartTime = New TimeSpan(10, 0, 0)

    'Set the format style that you want to apply

    exception.HourRange.FormatStyle.BackColor = Color.Red



    'Add the WorkingHourException to the Exceptions collection of the WorkingHourSchema

    Me.Schedule1.WorkingHourSchema.Exceptions.Add(exception)





    In C#



    //Create a new WorkingHourException

    WorkingHourException exception = new WorkingHourException();



    //Specify the date range where you want to give the format

    //Note: The date range must be of at least one day, and use the StartTime and EndTime //properties of the HourRange to set the time of the day where the format will be applied

    exception.DateRange = new DateRange(new DateTime(2006, 1, 16), new DateTime(2006, 1, 17));



    //Specify the start and end time that you want to format

    exception.HourRange.EndTime = new TimeSpan(14, 0, 0);

    exception.HourRange.StartTime = new TimeSpan(10, 0, 0);

    //Set the format style that you want to apply

    exception.HourRange.FormatStyle.BackColor = Color.Green;



    //Add the WorkingHourException to the Exceptions collection of the WorkingHourSchema

    this.Schedule1.WorkingHourSchema.Exceptions.Add(exception);







    The following code shows how to use the RecurrencePattern property of the ScheduleHourRange object to apply the format style for the rows based on a recurrence pattern



    In VB:



    Dim recurrencePattern As New WorkingHourRecurrencePattern()

    'Call the BeginEdit before changing the properties of the RecurrencePattern

    recurrencePattern.BeginEdit()





    'Specify the recurrence pattern. In this case the 10th of every month is the date that 'will be formatted

    recurrencePattern.SetDefaultValuesForDate(DateTime.Today)

    recurrencePattern.PatternStartDate = DateTime.Today

    recurrencePattern.RecurrenceEndMode = RecurrenceEndMode.NoEndDate

    recurrencePattern.RecurrenceType = RecurrenceType.Monthly

    recurrencePattern.StartTime = New TimeSpan(8, 0, 0)

    recurrencePattern.EndTime = New TimeSpan(10, 0, 0)

    recurrencePattern.DayOfMonth = 10



    recurrencePattern.EndEdit()



    'Create the new ScheduleHourRange that will be added to the WorkingHourSchema

    Dim hourRange As New ScheduleHourRange()



    'Set the RecurrencePattern that will be used

    hourRange.RecurrencePattern = recurrencePattern



    'Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red



    'Add the ScheduleHourRange to the WorkingHourSchema of the Schedule

    Me.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange)





    In C#



    WorkingHourRecurrencePattern recurrencePattern = new WorkingHourRecurrencePattern();

    //Call the BeginEdit before changing the properties of the RecurrencePattern

    recurrencePattern.BeginEdit();



    //Specify the recurrence pattern. In this case the 10th of every month is the date that //will be formatted

    recurrencePattern.SetDefaultValuesForDate(DateTime.Today);

    recurrencePattern.PatternStartDate = DateTime.Today;

    recurrencePattern.RecurrenceEndMode = RecurrenceEndMode.NoEndDate;

    recurrencePattern.RecurrenceType = RecurrenceType.Monthly;

    recurrencePattern.StartTime = new TimeSpan(8, 0, 0);

    recurrencePattern.EndTime = new TimeSpan(10, 0, 0);

    recurrencePattern.DayOfMonth = 10;



    recurrencePattern.EndEdit();



    //Create the new ScheduleHourRange that will be added to the WorkingHourSchema

    ScheduleHourRange hourRange = new ScheduleHourRange();



    //Set the RecurrencePattern that will be used

    hourRange.RecurrencePattern = recurrencePattern;



    //Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red;



    //Add the ScheduleHourRange to the WorkingHourSchema of the Schedule

    this.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange);







    If you want to modify only the rows of a particular owner then use the WorkingHourSchema property of the ScheduleAppointment owner to add the ScheduleHourRange



    In VB:



    Dim owner As ScheduleAppointmentOwner = Me.Schedule1.Owners(0)

    owner.WorkingHourSchema.WorkingHoursRange.Add(hourRange)



    In C#



    ScheduleAppointmentOwner owner = this.Schedule1.Owners[0];

    owner.WorkingHourSchema.WorkingHoursRange.Add(hourRange);


    Source Of Information : Janus v3.5 Help Files for VS 2008


0 comments:

Leave a Reply