Clear Selected Date in Calendar

4 posts, 0 answers
  1. Cesar
    Cesar avatar
    20 posts
    Member since:
    Oct 2012

    Posted 29 Jan 2014 Link to this post

    Hi;

    I am trying to delete the selected day in the calendar. Is it possible not to have any day selected? The Clear button select Today. I tried to use a Context Menu with a event having this code:

                    this.rCalendario.SelectedDates.Clear();

                    this.rCalendario.SelectedDate = new DateTime();

    And again select a day.

    Can you help me?

    Thanks
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Jan 2014 Link to this post

    Hello Cesar,

    Thank you for writing.

    The selected dates should be cleared when you call the Clear method of the collection. I assume that the focused date is remaining. If so, it can be cleared as follows:
    private void radButton1_Click(object sender, EventArgs e)
     {
        RadElementCollection children = radCalendar1.CalendarElement.CalendarVisualElement.Children[0].Children[1].Children;
        for (int i = 0; i < children.Count; ++i)
        {
            CalendarCellElement cell = (CalendarCellElement)children[i];
            if (cell.Focused)
            {
                cell.Focused = false;
            }
        }
    }

    I hope this helps. Let us know if you have any other questions.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - 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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Cesar
    Cesar avatar
    20 posts
    Member since:
    Oct 2012

    Posted 03 Feb 2014 in reply to Stefan Link to this post

    Thanks, I've had to change some of the code for MultipleView:
    private void EliminarFocoCalendario()
    {
        RadElementCollection children = this.rCalendario.CalendarElement.CalendarVisualElement.Children[0].Children[1].Children;
        for (int i = 0; i < children.Count; i++)
        {
            RadElementCollection colCells = (RadElementCollection)children[i].Children[0].Children[1].Children;
     
            for (int j = 0; j < colCells.Count; j++)
            {
                CalendarCellElement cell = (CalendarCellElement)colCells[j];
     
                if (cell.Focused)
                {
                    cell.Focused = false;
                }
            }
        }
    }

    I've another question: ¿How can I chage ForeColor property in a SpecialDay?

    Regards
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 03 Feb 2014 Link to this post

    Hi Cesar,

    I am glad I could point you to the right direction.

    For the other question, may I please ask you to open a new thread for it in order to avoid mixing different subjects in the same thread. Thank you for the understanding.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - 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