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.
Unfortunately, activation email could not send to your email. Please try again.

Disable some dates

Thread ID:

Created:

Updated:

Platform:

Replies:

117742 Dec 5,2014 08:43 AM Dec 9,2014 06:54 AM Windows Forms 4
loading
Tags: DateTimePickerAdv
Mateus Caires da Silva
Asked On December 5, 2014 08:43 AM

Hi,
I need to disable some dates into DateTimePickerAdv, is it possible?
For example, I have a dates range: { 20/12/2014, 21/12/2014, 22/12/2014 }
I need to disable the midle one or in others situations the last one, can anybody help me?

Thank you.

Ashwini Jaya Preetha Durai Samy [Syncfusion]
Replied On December 8, 2014 06:00 AM

Hi Mateus,

 

Thank you for using Syncfusion products,

 

The reported requirement of disabling the dates in DateTimePickerAdv can be achieved by handling the DateCellQueryInfo event of calendar as shown in the below code snippet.

Code snippet[C#]:

 

void Calendar_DateCellQueryInfo(object sender, Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs e)

        {

            // This event enables user to customize MonthCalenderAdv DateCells

            if (e.RowIndex == 3 && e.ColIndex > 6)

            {

                e.Style.BackColor = Color.Snow;

 

                e.Style.Enabled = false;            

            }

            else

            {

                // To set selectable Date cells BackColor

                e.Style.BackColor = Color.FromArgb(13, 134, 64);

            }

 

        }

 

 

We have also prepared a sample and it can be downloaded from the following link:

 

Sample link: http://www.syncfusion.com/downloads/support/directtrac/131842/datetimepicker695623093.zip

 

Please let us know if you need further assistance,

 

Regards,

Ashwini


Mateus Caires da Silva
Replied On December 8, 2014 06:53 AM

Hi Ashwini,
Thank you for the response, I have tried in the DateCellQueryInfo event but is not possible invalidate the click in a invalid date and the calendar popup is closed, there is a solution for it?

Tank you so much!
Mateus

Mateus Caires da Silva
Replied On December 9, 2014 06:47 AM

Hi Guys,
I've found the solution

Code snippt[c#]
private void PopupWindow_BeforeCloseUp(object sender, CancelEventArgs e)
{
if(somecondition)
e.Cancel = true;
}

Thank you!

Ashwini Jaya Preetha Durai Samy [Syncfusion]
Replied On December 9, 2014 06:54 AM

Hi Mateus,

 

Thank you for the update,

 

Please let us know if you need further assistance.

 

Regards,

Ashwini


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;