Bolding day text in radcalendar based on certain events

5 posts, 1 answers
  1. Brennan
    Brennan avatar
    5 posts
    Member since:
    Jul 2010

    Posted 03 Sep 2010 Link to this post

    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?
  2. Answer
    Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 08 Sep 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brennan
    Brennan avatar
    39 posts
    Member since:
    Sep 2010

    Posted 10 Sep 2010 Link to this post

    Thanks Dobry!
  5. Tim
    Tim avatar
    1 posts
    Member since:
    Nov 2013

    Posted 25 Nov 2013 Link to this post

    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.
  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 28 Nov 2013 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready