add feture to datetimepicker

1 Answer 19 Views
Calendar, DateTimePicker, TimePicker and Clock DateTimePicker
ebrahim
Top achievements
Rank 1
Iron
Iron
ebrahim asked on 04 Jan 2022, 11:46 AM

hi

i have tow problem

1-how to change backcolor all friday(days) on calendar(datetimepicker)

my code not work


private void radDateTimePickerStart_ElementRender(object sender, RenderElementEventArgs e)
        {
            if (e.Day.Date.DayOfWeek==DayOfWeek.Friday)
            {
               
                e.Element.BackColor = Color.Red;


            }
           
        }

2-in atache image

title calendar not change CultureInfo("fa-IR", true);

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 07 Jan 2022, 09:38 AM

Hi Ebrahim,

Thank you for the provided image.

I have tried the code snippet your post and it is working as expected. The Fridays in the current month have different colors. Keep in mind that the cells are reused so you will need to reset the color otherwise the color will be applied to different cells. Check the following code snippet and let me know if it works for you.

private void Calendar_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date.DayOfWeek == DayOfWeek.Friday)
    {
        e.Element.BackColor = Color.Bisque;
    }
    else
    {
        e.Element.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
    }
}

As for your second question, you are right that when PersianCalendar is used, zooming years will not show the correct year. We are already aware of this behavior and it is logged in our Feedback Portal where you can track its progress. At this moment of writing this reply, I can't suggest a suitable workaround for this behavior. However, I have increased the priority of the feedback item so that our development team could consider fixing this in one of our next releases.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ebrahim
Top achievements
Rank 1
Iron
Iron
commented on 07 Jan 2022, 06:59 PM

hi mr dinko

by your code The headers of the week are also colored. It is clear in the attached photo

Dinko
Telerik team
commented on 10 Jan 2022, 11:59 AM

You are right. When changing the months at some point the color is applied to the top row. What you can do is to extend the IF clause. You can check if the Row property of the e.Element is bigger than 0.

private void Calendar_ElementRender(object sender, RenderElementEventArgs e)
{
    var cell = e.Element as CalendarCellElement;
    if (e.Day.Date.DayOfWeek == DayOfWeek.Friday && (cell.Row > 0))
    {
        e.Element.BackColor = Color.Bisque;
    }
    else
    {
        e.Element.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
    }
}

ebrahim
Top achievements
Rank 1
Iron
Iron
commented on 10 Jan 2022, 12:19 PM

HI MR DINKO

TANKS

Yes it did

Tags
Calendar, DateTimePicker, TimePicker and Clock DateTimePicker
Asked by
ebrahim
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko
Telerik team
Share this question
or