This is a migrated thread and some comments may be shown as answers.

use of colours on Rad Calendar/time picker

1 Answer 91 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 02 Jun 2009, 03:12 PM
Hi
what i want to do is have a specific colour for a day and time in the date time picker/calendar if say a day is full of appointments and or if a day is half full or a day is empty and the same on the time picker if a time slot is taken or not

is there a way of doing this in c# asp.net?

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Jun 2009, 08:30 AM
Hello Kevin,

You can add SpecialDays to RadCalendar in order to give specific color/formatting.

CS:
 
protected void Button1_Click(object sender, EventArgs e) 
    RadCalendarDay day = new RadCalendarDay(); 
    day.Date = DateTime.Now;   // Day want to show in specific color 
    day.ItemStyle.BackColor = System.Drawing.Color.Red; 
    RadDateTimePicker1.Calendar.SpecialDays.Add(day); 

You can access the time item at ItemDataBound event and modify its styling there as shown below.
CS:
 
protected void RadDateTimePicker1_ItemDataBound(object sender, Telerik.Web.UI.Calendar.TimePickerEventArgs e) 
    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) 
    { 
        DataRowView dataItem = (DataRowView)e.Item.DataItem; 
        DateTime boundTime = (DateTime)dataItem.Row["Time"]; 
        if (boundTime.Hour == 10)  // Check Condition 
        {                 
            e.Item.BackColor = System.Drawing.Color.Red; 
        } 
        else if (boundTime.Hour == 11) //Check Condition 
        { 
            e.Item.BackColor = System.Drawing.Color.Yellow; 
        } 
    } 

Thanks,
Shinu.
Tags
Calendar
Asked by
Kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or