Link to home
Start Free TrialLog in
Avatar of ccravenbartle
ccravenbartle

asked on

VB.Net datetimepicker control - how to change the textbox forecolor

This should be easy but I can't figure it out.  With VB.Net how do you change the forecolor of the datetimepicker textbox?  

I can see various properties that can be used to change the colors of the calendar but I can't see a property for changing the forecolor of the date that is displayed in the text box once the user has picked the date.

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

It doesn't have that property.

Bob
Avatar of ccravenbartle
ccravenbartle

ASKER

Rats.  This is a bit of a blow.  My program compares the date selected with another date and, if it is earlier than the other date, the date is accepted but displayed in red to warn the user that there may be a problem.  Any ideas on how I could do this if there is no forecolor text property available with the datetimepicker?
Have you thought of using the ErrorProvider?

ErrorProvider1.SetError(DateTimePicker1, "Warning Message!")

It will show an icon next to the date time picker, and provide the warning message as a tooltip.

At the very least, you could hide/unhide a label above the control.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Eric,

What did that article say about ForeColor?

Bob
It shows how to override the OnPaint method of the DateTimePicker to draw the string the way (and the color) you want.
Cool b-)  Thanks :D

Bob