views:

40

answers:

1

hello

I want to set the days of a datetimepicker in english

but unfortunatly, the datetime picker don't support culture

so I think I can inherit the control, and set the days and months name by myself

but I don't know how

anybody has an idea for that ?

thanks in advance

Sam

A: 

You can start with overriding OnPaint as outlined here: derived DateTimePicker

When you get to the part where you're setting the text, you can take out the reference to this.Text and put in your own string. Something like this:

     Thread.CurrentThread.CurrentCulture = 
                    CultureInfo.CreateSpecificCulture("en-US");
     string newlyFormattedText = this.Value.ToString("dddd, MMMM dd, yyyy");
     g.DrawString(newlyFormattedText, this.Font, Brushes.Black, 0, 2);
msergeant
how can I get the part where I set the month and day text ??
Sam
I may have been too subtle before. I've changed the code to show how to change your date to a US format. You can change this to whatever culture and whatever format you'd like.
msergeant
I think Sam wanted to know how to draw it in the right place, though...
Ant
Ant : yes I do ;-)
Sam
Oh yes. I guess you would want to change the month and day text that appears in the dropdown as well. I'm not sure how to do that one.
msergeant