We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable or hide the previous and next months' dates in DateTimePickerAdv

Platform: WinForms |
Control: DateTimePickerAdv |
Published Date: April 30, 2011 |
Last Revised Date: June 27, 2019

How to disable or hide the previous and next months' dates in DateTimePickerAdv?

 

By default, the trailing date (previous and next months' dates) is visible in the drop-down calendar of the DateTimePickerAdv. You can hide the trailing dates by setting forecolor of trailing dates to White in the DateCellQueryInfo event. The following code example demonstrates how to hide trailing dates in the drop-down calendar of the DateTimePickerAdv.

C#

    

 

    this.dateTimePickerAdv1.Calendar.DateCellQueryInfo += new DateCellQueryInfoEventHandler(Calendar_DateCellQueryInfo);

        /// <summary>

        /// Event to provide custom formatting for calendar cells.

        /// </summary>

        void Calendar_DateCellQueryInfo(object sender, DateCellQueryInfoEventArgs e)

        {

            if (e.Style.TextColor == this.dateTimePickerAdv1.CalendarTrailingForeColor)

            {

                // Hide the trailing dates

                e.Style.Enabled = false;

                e.Style.TextColor = Color.White;

 

            }

 

        }

VB

             AddHandler dateTimePickerAdv1.Calendar.DateCellQueryInfo, AddressOf Calendar_DateCellQueryInfo

              ''' <summary>

  '''Event to provide custom formatting for calendar cells.

  ''' </summary>

  Private Sub Calendar_DateCellQueryInfo(ByVal sender As Object, ByVal e As DateCellQueryInfoEventArgs)

   If e.Style.TextColor = Me.dateTimePickerAdv1.CalendarTrailingForeColor Then

    'Hide the trailing dates

    e.Style.Enabled = False

    e.Style.TextColor = Color.White

 

   End If

 

  End Sub

Pop-up calendar without trailing dates

 

Sample:

C#: http://www.syncfusion.com/downloads/support/directtrac/general/ze/CS-1146374136

VB: http://www.syncfusion.com/downloads/support/directtrac/general/ze/VB-1476170831

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon