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

Bolding day text in radcalendar based on certain events

4 Answers 156 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Brennan
Top achievements
Rank 1
Brennan asked on 03 Sep 2010, 04:39 PM
Is it possible to bold the day text in the radcalendar based on certain events? For example, I want to "lock" certain dates, say from Dec. 1st to Dec. 20th and to show that they are "locked" i want to bold the day text for days 1 - 20 in the calendar.  To "lock" these days I would click a button, for example, and the selected date and all dates prior would be bolded (locked).  Is it possible to do this?

4 Answers, 1 is accepted

Sort by
0
Accepted
Dobry Zranchev
Telerik team
answered on 08 Sep 2010, 05:21 PM
Hello Brennan,

Thank you for writing.

You can subscribe to the ElementRender event of RadCalendar. In this event you can define the style of the font:
void radCalendar1_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date == new DateTime(2010, 9, 6))
    {
        Font font = new Font(e.Element.Font, e.Element.Font.Style | FontStyle.Bold);
        e.Element.Font = font;
    }
    else
    {
        Font font = new Font(e.Element.Font, e.Element.Font.Style & ~FontStyle.Bold);
        e.Element.Font = font;
    }
}

I hope that this will help you. If you have other questions, feel free to write back.

Greetings,
Dobry Zranchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brennan
Top achievements
Rank 1
answered on 10 Sep 2010, 04:44 PM
Thanks Dobry!
0
Tim
Top achievements
Rank 1
answered on 25 Nov 2013, 11:14 AM
Hi!

I'm using that event you mentioned to color font in Cell (e.Element.Text = "Text"; e.Element.ForeColor=Color.Red;), and it works fine when I change month in calendar. But this event seems not to fire after RadCalendar is created and shown. How to force to fire ElementRender event after control is crated and shown?

Best Regards,
Tomasz.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Nov 2013, 08:26 AM
Hello Tim,

Thank you for contacting Telerik Support.

In order to refresh the calendar after it is initialized, you may use the following code snippet:
public Form1()
{
    InitializeComponent();
 
    radCalendar1.InvalidateCalendar();
}
 
private void radCalendar1_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date > new DateTime(2013, 11, 6) && e.Day.Date < new DateTime(2013, 11, 26))
    {
        Font font = new Font(e.Element.Font, e.Element.Font.Style | FontStyle.Bold);
        e.Element.Font = font;
    }
    else
    {
        Font font = new Font(e.Element.Font, e.Element.Font.Style & ~FontStyle.Bold);
        e.Element.Font = font;
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Brennan
Top achievements
Rank 1
Answers by
Dobry Zranchev
Telerik team
Brennan
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or