开发者

How to disable the "Today" line at the bottom of DateTimePicker + Hide WeekEnds [duplicate]

This question already has answers here: 开发者_运维知识库 How can I remove the "Today" button from DateTimePicker control (of Windows form Control) (2 answers) Closed last year.

It's all in the question title :-)

I want to get totally rid of the "Today" feature of DateTimePicker

and find a way to "Hide" or gray out WeekEnds.

If somebody has hints on how to code such extensions, or on some free downloadable extended DTPickers that could help do this, i'd be very interested.

I know How Customizing Default .net Controls can be a real pain, But I'm a courageous and stout hearted developer and extending the DateTimePicker by overrding WMPAINT, WndProc, and such stuff doesn't scare me anymore :-)


Here is what worked for me as a workaround to avoid weekend, not sure on the today feature,I implemented a check to see which day of the week it was then from the you could choose to notify user to pick another date or warn them.

private void bookingDateDateTimePicker_ValueChanged(object sender, EventArgs e)
    {
        int x = ((int)DateTime.Parse(bookingDateDateTimePicker.Text).Date.DayOfWeek);


        //this will check in the selected date fall son the weekend or not 
        if ( x>5||x<1)
        {
            //Reject
            MessageBox.Show("Looks like this booked on the weekend, please make sure this is a work day "+x);
        }
        else
        {
            //Accept
            
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜