Day selection

12 posts, 0 answers
  1. Shirya
    Shirya avatar
    40 posts
    Member since:
    Sep 2008

    Posted 17 Feb 2009 Link to this post

    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
  2. Shirya
    Shirya avatar
    40 posts
    Member since:
    Sep 2008

    Posted 17 Feb 2009 Link to this post

    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

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 19 Feb 2009 Link to this post

    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.
  5. Shirya
    Shirya avatar
    40 posts
    Member since:
    Sep 2008

    Posted 20 Feb 2009 Link to this post

    Thank you!
  6. Shirya
    Shirya avatar
    40 posts
    Member since:
    Sep 2008

    Posted 20 Feb 2009 Link to this post

    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

     

     

     

     

     

  7. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 24 Feb 2009 Link to this post

    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.
  8. Shirya
    Shirya avatar
    40 posts
    Member since:
    Sep 2008

    Posted 05 Mar 2009 Link to this post

    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) ?
  9. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 09 Mar 2009 Link to this post

    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.
  10. Anjan Guha
    Anjan Guha avatar
    6 posts
    Member since:
    Jul 2009

    Posted 24 Jul 2009 Link to this post

    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;
                                         

                    }

                }

  11. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 28 Jul 2009 Link to this post

    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.
  12. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 18 Sep 2009 Link to this post

    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
  13. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 23 Sep 2009 Link to this post

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