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

Day selection

11 Answers 215 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Shirya
Top achievements
Rank 1
Shirya asked on 17 Feb 2009, 08:09 PM
Hello,
i can't seem to figure out how to select several days in my calendar.
I have a list of dates that i would like to select in my calendar. How can i do this?
I set the property AllowMultipleSelect tro true and tried something like that but  no dates are selected:

   For  each myDate in DateList
            Me.RadCalendar1.SelectedDates.Add(myDate
        Next 
thanx

11 Answers, 1 is accepted

Sort by
0
Shirya
Top achievements
Rank 1
answered on 17 Feb 2009, 09:13 PM
never mind: i had the time in my dates. I removed the time and now it show the selected date.
But i have another question: I would like to disable the days that are not in my DateList.
How can i do that?
thanks

0
Boyko Markov
Telerik team
answered on 19 Feb 2009, 03:21 PM
Hi Shirya,

You can get an instance of any cell element in RadCalendar and set its properties such as the Enabled property. When you set Enabled = false then you will no longer be able to select that cell using the mouse or the keyboard.

Here is sample code which disables all cells in RadCalendar

For Each cell As CalendarCellElement In (TryCast(Me.radCalendar1.CalendarElement.CalendarVisualElement, MonthViewElement)).TableElement.Children 
cell.Enabled = False 
Next cell 

You can check what is the current cell date using the Date property of CalendarCellElement class.

I hope that this will help you. Do not hesitate to contact me back if you have further questions.

Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Shirya
Top achievements
Rank 1
answered on 20 Feb 2009, 02:45 PM
Thank you!
0
Shirya
Top achievements
Rank 1
answered on 20 Feb 2009, 04:47 PM
Hello,
I tryed you solution and it works, but only in the current month.
when i navigate through my calendar, all the days are disable except the days in my date list.
I would like to enable only the days of the month  in my dateList.
How can i do that?

i try this too but stil the same result

 

 
 
For Each myCell As UI.CalendarCellElement In RadCalendarStartDate.RootElement.Children(0).Children(0).Children(2).Children(0).Children(1).Children   
     If Not Me.Dates.Contains(myCell.Date) Then   
        myCell.Enabled = False 
    End If    
Next  
 
 

 


thank you
Shirya

 

 

 

 

 

0
Jordan
Telerik team
answered on 24 Feb 2009, 09:51 AM
Hello Shirya,

You could try also using the code (that disables cells) in the handler of the ViewChanged event of RadCalendar so that it is executed every time the user navigates to a different month.

You may also need to change the code a little bit so that it also enables cells for dates that are in your list.

I hope this helps.

All the best,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Shirya
Top achievements
Rank 1
answered on 05 Mar 2009, 08:06 PM
hello again,
Weekend and normal days do not have the same look when disabled. How can i have the same gray backcolor for all the disabled days (even if its not a weekend day) ?
0
Boyko Markov
Telerik team
answered on 09 Mar 2009, 02:21 PM
Hello Shirya,

I think this issue is theme related and I have a very simple workaround. You can set the color properties of the calendar cells: BackColor, BackColor2, BackColor3, BackColor4, GradientStyle, etc.

Please take a look at the sample code below:

foreach (CalendarCellElement cell in (this.radCalendar1.CalendarElement.CalendarVisualElement as MonthViewElement).TableElement.Children) 
     cell.BackColor = Color.Green; 

Please do not hesitate to contact me if you have any other questions regarding RadCalendar.

Regards,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Anjan Guha
Top achievements
Rank 1
answered on 24 Jul 2009, 04:12 PM
Hi
I want to disable all days except Monday for all Months in RAD dateTimePicker. I have wriiten the following Code but still able to select dates other than Monday... 

public Form1()
        {
            InitializeComponent();
            this.radDateTimePicker1.DateTimePickerElement.Opened +=new EventHandler(DateTimePickerElement_Opened);
           

   

        }

        private void DateTimePickerElement_Opened(object sender, EventArgs e)
        {
            CalendarTableElement table = ((this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as
                RadDateTimePickerCalendar).Calendar.CalendarElement.CalendarVisualElement.Children[0].Children[1] as
                CalendarTableElement);
            foreach (CalendarCellElement cell in table.Children)
            {
                cell.Enabled = true;
               
                if (cell.Date.DayOfWeek != DayOfWeek.Monday)
                {
                    cell.Enabled = false;
                                     

                }

            }

0
Boyko Markov
Telerik team
answered on 28 Jul 2009, 04:12 PM
Hello Anjan Guha,

This cannot be done with the current implementation of RadCalendar. The selection  cannot be canceled for a specific cell using the Enabled property. However this will be possible after we release the SP release this week.

Feel free to contact us again in case you have further questions after the SP1 release.
 

Best wishes,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
DK
Top achievements
Rank 2
answered on 18 Sep 2009, 08:10 AM
I want to show the default calender month
how can i do that.
example.

if i click on the calender  icon of the date picker then the current month  calender opens
but i need to open some other months calender.
how can i do it?

thanx in advance
0
Boyko Markov
Telerik team
answered on 23 Sep 2009, 02:56 PM
Hi DK,

Here is sample code which demonstrates how to show a month different than the current one when the user opens the RadCalendar popup in RadDateTimePicker:

1. Subscribe to the Opened event of the PopupControl

RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;  
calendarBehavior.PopupControl.Opened += new EventHandler(PopupControl_Opened); 

2. Set the calendar's FocusedDate property to any custom date.

void PopupControl_Opened(object sender, EventArgs e)  
{  
    DateTime myCustomDate = new DateTime(2000, 10, 20);  
    RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;  
    calendarBehavior.Calendar.FocusedDate = myCustomDate;  

I hope this helps.

Sincerely yours,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Shirya
Top achievements
Rank 1
Answers by
Shirya
Top achievements
Rank 1
Boyko Markov
Telerik team
Jordan
Telerik team
Anjan Guha
Top achievements
Rank 1
DK
Top achievements
Rank 2
Share this question
or