Replacing '01 -01-0001 'with an empty string based on DevExpress.XtraEditors.TextEdit control

In order not to change, datalayer returns DateTime.Mindatewhen the record column is NULL. Therefore, when you put a value nullin a column of a record and you read it again, you get 01-01-0001.

When binding this value to a value, DevExpress.XtraEditors.TextEdit controlthis value (01-01-0001) is displayed in the control.

Now we want to show that the control is empty (without content), but I do not know how to do this.

I found out that you can set a custom display text for the control if the object attribute is NULL, but this does not work, because the value is 01-01-0001not null either.

In short: if it is a date with a value 01-01-0001, do not show anything in the control, otherwise specify a date.

Any ideas?

+3
source share
2 answers

You can use DateEditinsteadTextEdit

Set the property NullDateto1-1-0001

Disable the drop-down button in the "Buttons" settings if you do not require it. It will look the same as TextEdit.

Image

+1
source

You can handle the event FormatEditValueto format the date the way you want.

In the other direction, you are using an event ParseEditValueto analyze user input.

+1
source

All Articles