DateTimePicker and visibility to Min/Max Dates.

C

Chris Shepherd

Greetings group,

I have a situation where I'd like to visibly see disabled dates on a
DateTimePicker. Frequently the Min and Max dates in the picker will be
set only to days apart, and so I would like this to be reflected in a
way other than it simply failing to select when they click. It seems
like this would be doable with a MonthCalendar control, however the
DateTimePicker itself doesn't seem to expose an internal MonthCalendar,
nor does it provide any kind of hihglighting options.

I'm open to any/all crazy suggestions. :)

Chris.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Chris Shepherd said:
Greetings group,

I have a situation where I'd like to visibly see disabled dates on a
DateTimePicker. Frequently the Min and Max dates in the picker will be set
only to days apart, and so I would like this to be reflected in a way
other than it simply failing to select when they click. It seems like this
would be doable with a MonthCalendar control, however the DateTimePicker
itself doesn't seem to expose an internal MonthCalendar, nor does it
provide any kind of hihglighting options.

I'm open to any/all crazy suggestions. :)

IIRC you can control how each cell will looks like in the control. You
could set the CssClass to a style that the text is not visible. So it will
be "invisible"
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

OZI said:
This must be for a WinForm, I don't see CssClass.

My bad, I though it was for a web app.

But still the idea is valid, just to try to have the same color of the
font/background in the needed cells.
 
C

Chris Shepherd

OZI said:
Are you saying MinDate and MaxDate properties will not do it for you?

Nope, try it yourself. Just add a DateTimePicker and a MinDate and
MaxDate, and for me, by default, it simply means the user can't click
those dates once the MonthCalendar control has dropped down. Visibly
there isn't a difference between a valid date in the current month and
an invalid date in the current month.

Chris.
 
C

Chris Shepherd

Ignacio said:
IIRC you can control how each cell will looks like in the control. You
could set the CssClass to a style that the text is not visible. So it will
be "invisible"

This isn't a web control, but a WinForms control.

Chris.
 
C

Chris Shepherd

Ignacio said:
My bad, I though it was for a web app.

But still the idea is valid, just to try to have the same color of the
font/background in the needed cells.

The trouble is visibility to those cells.

Chris.
 
O

OZI

Yes the Idea is valid in theory and thin air. I don't see how to control
each individual day format.
It is not available like on in the web control.
 
O

OZI

Okay so what you want to do with the invalid dates is to make them
invisible.
There must be a way to override the rendering, but I don't see how now.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

OZI said:
Yes the Idea is valid in theory and thin air. I don't see how to control
each individual day format.
It is not available like on in the web control.

You are right, it's not available.

You will have to do it yourself. Before doing that I advise you to google
aroudn for projects, this may be asked and answered before.
For example a query of datetimepicker color in google returned this:
http://www.codeproject.com/cs/miscctrl/extended_datetimepicker.asp

Otherwise take a look at some commercial options like Infragistics.
Infragistics implement a kind of CSS for windows controls that is super
cool, You can change the look of your application on the fly and the
controls are very configurable
 
C

Chris Shepherd

Ignacio said:
You will have to do it yourself. Before doing that I advise you to google
aroudn for projects, this may be asked and answered before.
For example a query of datetimepicker color in google returned this:
http://www.codeproject.com/cs/miscctrl/extended_datetimepicker.asp

Yeah, I had googled and found several similar but not quite examples of
other controls. I was just wondering if there was some kind of simpler
method that I had somehow missed.
Otherwise take a look at some commercial options like Infragistics.
Infragistics implement a kind of CSS for windows controls that is super
cool, You can change the look of your application on the fly and the
controls are very configurable

Looks cool, I may have to see if management will go for it.

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top