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

Clear Selected Date in Calendar

3 Answers 338 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Cesar
Top achievements
Rank 1
Cesar asked on 29 Jan 2014, 08:53 AM
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

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 31 Jan 2014, 02:18 PM
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 >>
0
Cesar
Top achievements
Rank 1
answered on 03 Feb 2014, 09:39 AM
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
0
Stefan
Telerik team
answered on 03 Feb 2014, 01:35 PM
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 >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Cesar
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Cesar
Top achievements
Rank 1
Share this question
or