KB Article A48
Visible to All Users

The DisplayFormat of an unbound editor is ignored after editing

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 Basic
Private 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; } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.