Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one calendar,in this calendar i have to disable all sunday date.

for that how can i do using csharp.


Note It is windows application.

in the run mode i have disable all sunday date.

please help me.

Regards & Thanks,
Narasiman P.
Posted

hii

i think it will definitely helps you...just go to this link
make your custom DateTimePicker Control.

http://forums.codeguru.com/showthread.php?289142-Disable-dates-on-date-timepicker-control[^]

Happy to Help.
 
Share this answer
 
Hi,
It is difficult to disable the sunday, instead of we can restrict the user not to select the sunday.

C#
DateTime lastDate;
        System.Text.RegularExpressions.Regex rg;
        bool valueChangingProgramatically = false;
        public Form1()
        {
            InitializeComponent();
            lastDate = dateTimePicker1.Value;
            rg = new System.Text.RegularExpressions.Regex("Sunday");
            if (lastDate < dateTimePicker1.Value)
                dateTimePicker1.Value = dateTimePicker1.Value.AddDays(1);

        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            if (!valueChangingProgramatically)
            {
                if (rg.IsMatch(dateTimePicker1.Value.ToLongDateString()))
                {
                    valueChangingProgramatically = true;
                    dateTimePicker1.Value = lastDate;
                    //here you can also show a messagebox if you want.
                }

            }
            else
                valueChangingProgramatically = false;
            lastDate = dateTimePicker1.Value;
        }


You can also use other custom control, please refer the below link
http://www.devexpress.com/Support/Center/p/Q148134.aspx


Best Regards
Muthuraja
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900