# Formatting Items

The **ElementRender** event will be fired before every element is painted. This allows to easily change the styles of the elements at runtime, or format the items upon a condition. The following example shows how you can change the border for a particular days.

## Formatting items in the ElementRender event.

```C#
private void RadCalendar1_ElementRender(object sender, RenderElementEventArgs e)
{
    if (e.Day.Date.DayOfWeek == DayOfWeek.Monday || e.Day.Date.DayOfWeek == DayOfWeek.Thursday)
    {
        e.Element.DrawBorder = true;
        e.Element.BorderColor = ColorTranslator.FromHtml("#51ab2e");
    }
    else
    {
        e.Element.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
        e.Element.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Local);
    }

}
```

```VB.NET
    Private Sub RadCalendar1_ElementRender(ByVal sender As Object, ByVal e As RenderElementEventArgs)
        If e.Day.Date.DayOfWeek = DayOfWeek.Monday OrElse e.Day.Date.DayOfWeek = DayOfWeek.Thursday Then
            e.Element.DrawBorder = True
            e.Element.BorderColor = ColorTranslator.FromHtml("#51ab2e ")
        Else
            e.Element.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local)
            e.Element.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Local)
        End If

    End Sub
```

> caption Figure 1: RadCalendar with custom cells border.

![WinForms RadCalendar With custom Cells Border](https://www.telerik.com/products/winforms/documentation/assets/4b8a7010e00619bc77b532fa00ace25d/calendar-formatting-items001.png)

## Refresh the visual elements at runtime.

Since the event is called when the calendar is made visible, you may need to trigger it again at run-time. This can be done by calling **RefreshVisuals** method.

### Trigger the ElementRender event at run-time.

```C#
radCalendar1.CalendarElement.RefreshVisuals();
```

```VB.NET
radCalendar1.CalendarElement.RefreshVisuals()
```

## See Also

* [Themes](https://www.telerik.com/products/winforms/documentation/controls/calendar/customizing-appearance/styling)

* [Using Templates](https://www.telerik.com/products/winforms/documentation/controls/calendar/customizing-appearance/using-templates)
