Articles in this section
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 clickPrivate Sub NoneButton_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)flag = trueEnd Sub'Occurs mouse button clickPrivate Sub NoneButton_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)flag = falseEnd Sub
'To prevent the popup window hidingPrivate Sub PopupWindow_BeforeCloseUp(ByVal sender As Object, ByVal e As CancelEventArgs)If flag Thene.Cancel = trueEnd IfEnd 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.DisplayCalendarEnd SubPrivate Sub Calendar_NoneButtonClick(ByVal sender As Object, ByVal e As EventArgs)dateTimePickerAdv1.DisplayCalendarEnd Sub

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/DateTimePickerAdv317971602.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied