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

RadCalendar SpecialDays Remove

6 Answers 307 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
zhen
Top achievements
Rank 1
zhen asked on 24 Aug 2010, 12:58 PM
I tried to remove my SpecialDays by using functon 'RadCalendar1.SpecialDays.Remove(mday)
but it seems doesn't working
 
Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
        Dim mdate As New Date
        mdate = RadCalendar1.SelectedDate
        Dim mDay As New Telerik.WinControls.UI.RadCalendarDay(mdate)
        RadCalendar1.SpecialDays.Add(mDay)
 
    End Sub
 
    Private Sub RadButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadButton2.Click
       
        Dim mDay2 As New Telerik.WinControls.UI.RadCalendarDay()
        mDay2.Date= RadCalendar1.SelectedDate
           mCalendarDay.Date.ToString("dd/MM/yyyy")
        RadCalendar1.SpecialDays.Remove(mDay2)
    End Sub
I wonder if its datetime format cause the problem?...cos it seems if i select a date e.g. '07/08/2010' (I am using en-GB format) it automatically covert it to US Datetime format when you try to remove it (Like '07/08/2010' will become '08/07/2010') , the system wouldn't throw any error, but this special day still in 'Radcalendar1.specialdays 's' List. can anybody please give me example code how to remove certain specialdays by code?
btw, the version i got is "2009.1.9.414"
thanks in advance! its urgent.

6 Answers, 1 is accepted

Sort by
0
zhen
Top achievements
Rank 1
answered on 26 Aug 2010, 10:34 AM
hi,, can any body tell me why Calendar.sepecialdays.remove function doesn't work properly?
please reply and also , if i want to select a block of 5 working days and automatically mark the next 2 working days as non-working day(which are not selectable). how can i do it in the code? please provide me some example code. thank you 
0
zhen
Top achievements
Rank 1
answered on 27 Aug 2010, 11:13 AM
ignore my first question i manage to get it remove successfully.
For Each mSubDateStr As String In mDateStr
    For Each mSpecialDay As RadCalendarDay In cldHolidayDate.SpecialDays
        If mSubDateStr.Length > 0 Then
 
            If mSpecialDay.Date = mSubDateStr Then
                mSpecialDay.Selected = False
                cldHolidayDate.SpecialDays.Remove(mSpecialDay)
                Exit For
            End If
 
        End If
    Next
 
 
Next
0
Julian Benkov
Telerik team
answered on 27 Aug 2010, 11:14 AM
Hi zhen,

Thank you for contacting us.

The SpecialDays.Remove method removes only the dates that are currently stored in this collection. We do not have methods that search for specific date in the SpecialDays collection and I agree that this could be a bit confusing. We will consider improving our API to cover this scenario in our upcoming releases.

Please consider the following code snippet  for your scenario:


Private
Sub radButton1_Click(sender As Object, e As EventArgs)
    Me.radCalendar1.SpecialDays.Add(New Telerik.WinControls.UI.RadCalendarDay(New DateTime(2010, 8, 5)))
End Sub
 
Private Sub radButton2_Click(sender As Object, e As EventArgs)
    Dim dateToFound As New DateTime(2010, 8, 5)
 
    For i As Integer = 0 To Me.radCalendar1.SpecialDays.Count - 1
        If Me.radCalendar1.SpecialDays(i).[Date] = dateToFound Then
            Me.radCalendar1.SpecialDays.Remove(Me.radCalendar1.SpecialDays(i))
            Exit For
        End If
    Next
End Sub

I hope this helps.

All the best,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
zhen
Top achievements
Rank 1
answered on 31 Aug 2010, 04:05 PM
Hi, Julian
thank you for your reply, the first issue now has been solved. but i got another one which is if i select a block of 5 days(including weekend) on my calendar, how do i mark the following next two days as not been selected and change its background color by code??   any events i need to use to implement it? thank you again!
0
Dobry Zranchev
Telerik team
answered on 03 Sep 2010, 12:46 PM
Hello zhen,

In order to implement your scenario you should subscribe for the ElementRenderer event of the RadCalendar. In this method you could apply a new cell color:
 
Me.radCalendar1.ElementRender += New RenderElementEventHandler(radCalendar1_ElementRender)
 
Private Sub radCalendar1_ElementRender(sender As Object, e As RenderElementEventArgs)
    If e.Day.[Date] = New DateTime(2010, 9, 6) Then
        e.Element.BackColor = Color.Red
        e.Element.DrawFill = True
    End If
End Sub

 
A bit off topic: In case you have obtained a copy of our controls through the company you work for, please ask the purchase holder to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our technical support services. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.


Greetings,
Dobry Zranchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
zhen
Top achievements
Rank 1
answered on 09 Sep 2010, 03:11 PM

thank you dobry,
will do it early next week.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
zhen
Top achievements
Rank 1
Answers by
zhen
Top achievements
Rank 1
Julian Benkov
Telerik team
Dobry Zranchev
Telerik team
Share this question
or