Skip to main content
A newer version of this page is available. .

DateFilterControl.CalendarFrom Property

Provides access to the Calendar control that displays the key date in the Date Filter range.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v19.1.Win.dll

Declaration

public CalendarControl CalendarFrom { get; }

Property Value

Type Description
CalendarControl

A CalendarControl that allows the end-user to select the range’s date or time.

Remarks

The CalendarFrom property provides access to a calendar that is always visible in the date picker drop-down panel, regardless of the DateFilterDashboardItem.FilterType setting. If the FilterType is set to the DateFilterType.Between value, the CalendarFrom property provides access to the calendar that displays the range’s start.

Example

This code snippet paints selected dates and dates contained in the underlying data in a custom manner.

Note

The complete sample project How to Customize the Date Filter Dashboard Item is available in the DevExpress Examples repository.

using DevExpress.DashboardWin;
using DevExpress.XtraEditors.Controls;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
// ...
    dashboardViewer1.DashboardItemControlCreated += DashboardViewer1_DashboardItemControlCreated;
// ...
    private void DashboardViewer1_DashboardItemControlCreated(object sender, DashboardItemControlEventArgs e)
    {
        if (e.DateFilterControl != null)
        {
            e.DateFilterControl.CalendarFrom.CustomDrawDayNumberCell += Calendar_CustomDrawDayNumberCell;
            e.DateFilterControl.CalendarTo.CustomDrawDayNumberCell += Calendar_CustomDrawDayNumberCell;
        }
    }

    DateTime minValue;
    DateTime maxValue;

    private void Calendar_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
    {
        CalendarControl calendar = sender as CalendarControl;

        if (e.Date > minValue && e.Date < maxValue)
            e.Style.BackColor = Color.FromArgb(80, 0, 100, 10);


        if (e.Selected && e.View == DateEditCalendarViewType.MonthInfo)
        {
            StringFormat dayFormat = new StringFormat();
            dayFormat.Alignment = StringAlignment.Center;
            dayFormat.LineAlignment = StringAlignment.Center;
            Rectangle rect = e.ContentBounds;
            rect.Inflate(2, 2);
            Font cellFont = new Font(calendar.CalendarAppearance.DayCell.Font.FontFamily, calendar.CalendarAppearance.DayCell.Font.Size + 2);
            e.Cache.FillRectangle(new SolidBrush(Color.Yellow), e.ContentBounds);
            e.Cache.Graphics.DrawString($"{e.Date.Day}", cellFont, Brushes.Black, rect, dayFormat);
            e.Handled = true;
        }
    }

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CalendarFrom property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also