How to remove treatment from a Datetimepicker

Asked

Viewed 271 times

-1

I use the Datetimerpicker component to use the heater and set the date, but I would like to remove the treatments of the component, because it makes it difficult to use the user, I already gave an optimized, but I wanted to improve.

  • What treatments?

  • The default treatment of it, for example if I type 31 in the month 02 it automatically arrow 28

  • This treatment also occurs when the year is leap?

  • We’re talking about Windows Forms?

  • 2

    If you want to remove these treatments, why don’t you just use a Maskedtextbox? It wouldn’t be more useful, or even easier?

  • @Brunorodrigues solved the problem there?

  • "I solved, "I had to create an override class using a Maskedbox and the Datetimepicker itself, it was beautiful!

Show 2 more comments

1 answer

0

In the Load event use this:

dt.CustomFormat = " ";
dt.Format = DateTimePickerFormat.Custom;

private void dtData_Reserva_ValueChanged(object sender, EventArgs e) {
    dtData_Reserva.CustomFormat = "dd/MM/yyyy";
    dtData_Reserva.Format = DateTimePickerFormat.Custom;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.