Description:
The DisplayFormat of an unbound editor is ignored after editing
Answer:
Problems with formatting occurs because an unbound text editor stores a value as a string, therefore formatting cannot be applied.
If you use XtraEditors 3 or higher, you may wish to set the editor's Mask.MaskType property to Numeric. In this case, the editor is forced to handle the edit value as a number and, therefore, it can format it.
If you wish not to use the Numeric (or DateTime) mask, please use the ParseEditValue event to convert a string to a number.
Visual BasicPrivate Sub TextEdit1_ParseEditValue(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs) Handles TextEdit1.ParseEditValue
If TypeOf e.Value Is String Then
e.Value = Convert.ToDecimal(e.Value)
End If
End Sub
C#private void textEdit1_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) {
if(e.Value is string)
try {
e.Value = Convert.ToDecimal(e.Value);
}
catch(FormatException) {
e.Value = 0.0;
}
}