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. Image for the cookie policy date

Disable some dates

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.

4 Replies

AJ Ashwini Jaya Preetha Durai Samy Syncfusion Team December 8, 2014 11:00 AM UTC

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



MC Mateus Caires da Silva December 8, 2014 11:53 AM UTC

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


MC Mateus Caires da Silva December 9, 2014 11:47 AM UTC

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!


AJ Ashwini Jaya Preetha Durai Samy Syncfusion Team December 9, 2014 11:54 AM UTC

Hi Mateus,

 

Thank you for the update,

 

Please let us know if you need further assistance.

 

Regards,

Ashwini


Loader.
Live Chat Icon For mobile
Up arrow icon