Skip to main content
A newer version of this page is available. .

RepositoryItem.ParseEditValue Event

Converts an input value (entered by a user or assigned in code) to the value that the editor will store.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[DXCategory("Events")]
public event ConvertEditValueEventHandler ParseEditValue

Event Data

The ParseEditValue event's data class is ConvertEditValueEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets a value specifying whether default edit value conversion/formatting is required.
Value Gets or sets either the edit or the display value of an editor.

Remarks

Each time a user changes the value, or a new value is assigned to the editor in code, this value is converted to the appropriate type (numeric, date/time, etc.). The ParseEditValue event fires at this time and allows you to implement a custom edit value conversion.

The event’s ConvertEditValueEventArgs.Value parameter allows you to obtain the current edit value. Set this parameter to the value that the editor should store (standalone editors store the new value in the BaseEdit.EditValue property). You must set the ConvertEditValueEventArgs.Handled property value to true to block the default conversion after your ParseEditValue event handler is complete.

Note

The ParseEditValue event may be called multiple times consecutively. The number of calls is different for different editor types and may also depend on the editor usage (standalone or embedded).

Refer to the Formatting topic for more information.

The code sample below illustrates how to convert the typed value into the decimal format.


RepositoryItemTextEdit te = new RepositoryItemTextEdit();
te.ParseEditValue += Te_ParseEditValue;
gridControl1.RepositoryItems.Add(te);
gridView1.Columns["Price"].ColumnEdit = te;

private void Te_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
{
    TextEdit edit = sender as TextEdit;
    try { e.Value = Convert.ToDecimal(e.Value); }
    catch (FormatException e2)
    {
        e.Value = 0.0;
    }
    e.Handled = true;
}
See Also