dashboard-devexpress-dot-dashboardwin-dot-datefiltercontrol-408ea88e.md
Provides access to the Calendar control that displays the key date in the Date Filter range.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public CalendarControl CalendarFrom { get; }
Public ReadOnly Property CalendarFrom As CalendarControl
| Type | Description |
|---|---|
| CalendarControl |
A CalendarControl that allows the end-user to select the range’s date or time.
|
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.
This code snippet paints selected dates and dates contained in the underlying data in a custom manner.
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;
}
}
Imports DevExpress.DashboardWin
Imports DevExpress.XtraEditors.Controls
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Drawing
Imports System.Linq
' ...
AddHandler dashboardViewer1.DashboardItemControlCreated, AddressOf DashboardViewer1_DashboardItemControlCreated
' ...
Private Sub DashboardViewer1_DashboardItemControlCreated(ByVal sender As Object, ByVal e As DevExpress.DashboardWin.DashboardItemControlEventArgs)
If e.DateFilterControl IsNot Nothing Then
AddHandler e.DateFilterControl.CalendarFrom.CustomDrawDayNumberCell, AddressOf Calendar_CustomDrawDayNumberCell
AddHandler e.DateFilterControl.CalendarTo.CustomDrawDayNumberCell, AddressOf Calendar_CustomDrawDayNumberCell
End If
End Sub
Private minValue As Date
Private maxValue As Date
Private Sub Calendar_CustomDrawDayNumberCell(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs)
Dim calendar As CalendarControl = TryCast(sender, CalendarControl)
If e.Date > minValue AndAlso e.Date < maxValue Then
e.Style.BackColor = Color.FromArgb(80, 0, 100, 10)
End If
If e.Selected AndAlso e.View = DateEditCalendarViewType.MonthInfo Then
Dim dayFormat As New StringFormat()
dayFormat.Alignment = StringAlignment.Center
dayFormat.LineAlignment = StringAlignment.Center
Dim rect As Rectangle = e.ContentBounds
rect.Inflate(2, 2)
Dim cellFont As 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
End If
End Sub
See Also