Category / Section
How to prevent the Calendar from hiding, on clicking the button "Today" or "None" in DateTimePickerAdv?
1 min read
You can prevent the calendar from hiding when you click either the "Today" button or the "None" button in DateTimePickerAdv by handling the Today or None button click event.
C#
bool flag = false;
//Occurs mouse button click
void NoneButton_MouseDown(object sender, MouseEventArgs e)
{
flag = true;
}
//Occurs mouse button click
void NoneButton_MouseUp(object sender, MouseEventArgs e)
{
flag = false;
}
//To prevent the popup window hiding
void PopupWindow_BeforeCloseUp(object sender, CancelEventArgs e)
{
if (flag)
e.Cancel = true;
}
//Another way
//To display the calendar when click on the Today or Non button
void TodayButton_Click(object sender, EventArgs e)
{
dateTimePickerAdv1.DisplayCalendar();
}
void Calendar_NoneButtonClick(object sender, EventArgs e)
{
dateTimePickerAdv1.DisplayCalendar();
}
VB
Dim flag As Boolean = false
'Occurs mouse button click
Private Sub NoneButton_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
flag = true
End Sub
'Occurs mouse button click
Private Sub NoneButton_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
flag = false
End Sub
'To prevent the popup window hiding
Private Sub PopupWindow_BeforeCloseUp(ByVal sender As Object, ByVal e As CancelEventArgs)
If flag Then
e.Cancel = true
End If
End Sub
'Another way to display the calendar when click on the Today or Non button
Private Sub TodayButton_Click(ByVal sender As Object, ByVal e As EventArgs)
dateTimePickerAdv1.DisplayCalendar()
End Sub
Private Sub Calendar_NoneButtonClick(ByVal sender As Object, ByVal e As EventArgs)
dateTimePickerAdv1.DisplayCalendar()
End Sub
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/DateTimePickerAdv317971602.zip