Remove focussed date selection on RadCalender

8 posts, 0 answers
  1. Rajeev
    Rajeev avatar
    10 posts
    Member since:
    Apr 2008

    Posted 09 Apr 2008 Link to this post

    Hi,

    I have 2 RadCalender on my window form just llike Microsoft Outlook which will show selection of date on Top Calender and Bottom calender don't have any selection. But my Bottom calender on my form has selection and tried to remove it but no success. If i don't set focusdate or selected date on bottom calender, it takes either default value set at design time or default Jan 1900. I want same behaviour as in Microsoft Outlook. Please help.
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 11 Apr 2008 Link to this post

    Hello Rajeev,

    You can use the SelectedDate or SelectedDates collection if you want to do some custom behavior with the selection in RadCalendar.  There are some properties such as AllowSelect, AllowMultipleSelect which could be of help.  

    You can also iterate through all of the cells in RadCalendar and set the cell's Selected property to false.This will cause the deletion of any visual selection state in RadCalendar. Also, you can call the InvalidateCalendar method of RadCalendar to refresh all its states to the values set.

    To iterate through the cells you can use:

    foreach (CalendarCellElement cell in radCalendar1.RootElement.Children[0].Children[0].Children[2].Children[0].Children[1].Children)
    {
    CalendarCellElement cl = cell as CalendarCellElement;

    d.Selected = false;
    }


    I hope this helps. Please contact me if you need more information.

    Best wishes,

    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Charlie
    Charlie avatar
    8 posts
    Member since:
    May 2008

    Posted 30 May 2008 Link to this post

    Hi, I'm trying to de-select "today" in a RadCalendar. Looking for RadControls' equivalent of visual studio's MonthCalendar.ShowTodayCircle. Iterating through the elements didn't work for me.

    I'm using Q1 2008; not using SP1 coz it broke one of my grids

    Thanks,

    Charlie
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 30 May 2008 Link to this post

    Hi Charlie,

    Thank you for contacting us.

    I can suggest the following:

    1. Subscribe to the ElementRender event of RadCalendar            

    this.radCalendar1.ElementRender += new Telerik.WinControls.UI.RenderElementEventHandler(radCalendar1_ElementRender);

    2. In the EventHandler of this event, please include the following code:                                                                                              

    void radCalendar1_ElementRender(object sender, Telerik.WinControls.UI.RenderElementEventArgs e)
            {
                if (e.Element as CalendarCellElement != null)
                {
                    (e.Element as CalendarCellElement).Today = false;
                }
            }

    I hope this helps. If you need more information please write me back.

    Best wishes,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Charlie
    Charlie avatar
    8 posts
    Member since:
    May 2008

    Posted 01 Jun 2008 Link to this post

    Hi again. Thanks for the reply.

    The solution you gave worked for the current month, but if you navigate to the previous month, "today" would still be highlighted and in a different way. Sort of like a negative highlight if that makes sense.

    Charlie
  7. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 05 Jun 2008 Link to this post

    Hi Charlie,

    I've tested the behavior I have sent you only with the default theme of RadCalendar.  After your response, I've tried it with the other themes too. If there is a special coloring for the other months' days, you can use the following:

       void radCalendar1_ElementRender(object sender, Telerik.WinControls.UI.RenderElementEventArgs e)
            {
                if (e.Element as CalendarCellElement != null)
                {
                    (e.Element as CalendarCellElement).Today = false;
                    (e.Element as CalendarCellElement).OtherMonth = false;
                }
            }

    As you can see, the CalendarCellElement class has a special behavior in different situations depending on selection, today's date, other month date, etc.

    I hope this helps.

    Greetings,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Charlie
    Charlie avatar
    8 posts
    Member since:
    May 2008

    Posted 05 Jun 2008 Link to this post

    Oh right, forgot to mention I was using the Office2007Black theme. I ended up turning off the ShowOtherMonthsDays in the designer; gets rid of the problem.

    I tried your solution and it actually shows other month's days like this month's, probably something in the theme. Thanks for your help.

    Charlie
  9. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 06 Jun 2008 Link to this post

    Hi Charlie,

    I'm happy to hear that.

    Indeed, it will show the other month's day as the month's when we set the OtherMonth property to false.
    Another solution was to hide the other month's days, but I thought that you will need them.

    Anyway, if you have any further questions on RadCalendar, do not hesitate to write me back.

    Kind regards,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready