Contents
- DateCellQueryInfo event
- DateHover event
Having trouble getting help?
Contact Support
Contact Support
Event Handling in Windows Forms MonthCalendarAdv(Classic)
26 Apr 20215 minutes to read
MonthCalendarAdv triggers events whenever the date is selected and changed. The most widely used events are discussed as follows.
- Border3DStyleChanged
- BorderColorChanged
- BorderSidesChanged
- BorderStyleChanged
- DateCellQueryInfo
- DateChanged
- FirstDayOfWeekChanged
- NoneButtonClick
- ShowWeekNumbersChanged
- StretchScrollImageChanged
- ThemedBorderChanged
- DateHover
DateCellQueryInfo event
The DateCellQueryInfo event is handled to provide custom formatting for calendar cells.
Members | Description |
---|---|
ColIndex | Specifies the column index of GridCell. |
DateValue | Specifies the date value. |
RowIndex | Specifies the row index of GridCell. |
Style | Specifies GridStyleInfo object. |
Handled | Indicates whether the event is handled. It is a bool value. |
IsCurrentCell | Returns the current cell at run time. |
IsOutsideRange | Specifies whether the query is outside the range of a month. |
EnableHighlightColor | Gets or sets the the value to indicate the highlight color of the selected date. |
Example
You can use this style parameter to set tooltips for MonthCalendarAdv control as follows. This example uses IsCurrentCell, IsOutsideRange, ColIndex and Handled members.
private void monthCalendarAdv1_DateCellQueryInfo(object sender,DateCellQueryInfoEventArgs e)
{
//To disable the highlight color of the selected date value
if (this.monthCalendarAdv1.Value.Date == DateTime.Today)
{
e.EnableHighlightColor = false;
}
//Identifies current cell and sets the tooltip text for the calendar
if (e.IsCurrentCell)
{
e.Style.CellTipText = "Syncfusion calendar control";
e.Style.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Flat;
e.Style.BackColor = Color.LightSteelBlue;
}
//Sets Tooltip text for the cells outside range
else if (e.IsOutsideRange)
e.Style.CellTipText = "Outside range";
//Sets Cell Appearance to "Raised" for fourth Column
else if (e.ColIndex == 4)
e.Style.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Raised;
else
//event is stopped
e.Handled = false;
}
Private Sub monthCalendarAdv1_DateCellQueryInfo(ByVal sender As Object, ByVal e AsDateCellQueryInfoEventArgs)
If Me.monthCalendarAdv1.Value.Date = DateTime.Today Then
'To disable the highlight color of the selected date value
e.EnableHighlightColor = False
End If
'Identifies current cell and sets the tooltip text for the calendar
If e.IsCurrentCell Then
e.Style.CellTipText = "Syncfusion calendar control"
e.Style.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Flat
e.Style.BackColor = Color.LightSteelBlue
'Sets Tooltip text for the cells outside range
ElseIf e.IsOutsideRange Then
e.Style.CellTipText = "Outside range"
'Sets Cell Appearance to "Raised" for fourth Column
ElseIf e.ColIndex = 4 Then
e.Style.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Raised
Else
e.Handled = False
'event is stopped
End If
End Sub
NOTE
- In Fig 1, 18th is identified as the current cell and the tooltip is displayed. Also the background of the current cell is painted with LightSteelBlue.* Edges of the 4th column cells (ColIndex=4), other than the current cell are set to “Raised” and hence shows a raised appearance. * In Fig 2, user tries to query the cells outside the range, i.e inactive month dates and the respective tooltip is displayed.
DateHover event
The DateHover event is handled when mouse hover on the calendar cells and to assign SuperToolTip for calender cells.
Members | Description |
---|---|
ColIndex | Specifies the column index of GridCell. |
DateValue | Specifies the date value. |
RowIndex | Specifies the row index of GridCell. |
Cancel | Gets or sets a value indicating whether the event should be canceled. |
CellButton | Gets the cell button that is the target of the current mouse operation or NULL when the cell itself is the target. |
ToolTip | Gets or sets the TooltipInfo for the SuperToolTip. |
ToolTipStyle | Gets or sets the ToolTipStyle of the SuperToolTip. |
Model | Gets the Calendar model. |
//This event triggers once mouse hover on date
this.monthCalendarAdv1.DateHover += new Syncfusion.Windows.Forms.Tools.DateHoverEventHandler(monthCalendarAdv1_DateHover);
void monthCalendarAdv1_DateHover(object sender, Syncfusion.Windows.Forms.Tools.DateHoverEventArgs e)
{
e.ToolTip.Body.Text = e.DateValue.ToString();
e.ToolTipStyle = Syncfusion.Windows.Forms.Tools.ToolTipStyle.Ballon;
}
AddHandler monthCalendarAdv1.DateHover, AddressOf monthCalendarAdv1_DateHover
'This event triggers once mouse hover on date
Private Sub monthCalendarAdv1_DateHover(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.DateHoverEventArgs)
e.ToolTip.Body.Text = e.DateValue.ToString()
e.ToolTipStyle = Syncfusion.Windows.Forms.Tools.ToolTipStyle.Ballon
End Sub
The following screenshot illustrates the SuperToolTip when mouse hover on the respective date value by using DateHover event.