I apply a mask dynamically to a fieldvalue. In the editor mode this all works fine, bith in inline edit as well as detailview. The actual value is stored 'as is', i.e. without mask literals.
When the value is shown in a regular listview, it is shown as is, i.e. without the mask. How can I show the value with the mask applied in the listview?
Thanks.
C#protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
if (View is ListView)
{
var gridListEditor = ((ListView)View).Editor as ASPxGridListEditor;
var propertyEditor = gridListEditor.FindPropertyEditor("Reference", ViewEditMode.Edit) as ASPxPropertyEditor;
propertyEditor.EditMaskType = EditMaskType.Simple;
propertyEditor.EditMask = referenceMask;
propertyEditor.DisplayFormat = String.Format("{{0:{0}}}", referenceMask);
if (propertyEditor.Control == null)
propertyEditor.ControlCreated += ReferencePropertyEditor_ControlCreated;
else
SetMaskSettings(propertyEditor);
}
else if (View is DetailView)
{
var propertyEditor = ((DetailView)View).FindItem("WorkOrderReferenceID") as ASPxPropertyEditor;
propertyEditor.EditMaskType = EditMaskType.Simple;
propertyEditor.EditMask = referenceMask;
propertyEditor.DisplayFormat = String.Format("{{0:{0}}}", referenceMask);
if (propertyEditor.Control == null)
propertyEditor.ControlCreated += ReferencePropertyEditor_ControlCreated;
else
SetMaskSettings(propertyEditor);
}
}
private void ReferencePropertyEditor_ControlCreated(object sender, EventArgs e)
{
SetMaskSettings(sender as ASPxPropertyEditor);
}
private static void SetMaskSettings(ASPxPropertyEditor sender)
{
var editor = ((ASPxTextBox)sender.Editor);
editor.MaskSettings.IncludeLiterals = MaskIncludeLiteralsMode.None;
}