CustomMaskEventArgs.SetResult(String, Int32, Nullable<Int32>) Method
Sets the editor text, cursor position, and selection anchor.
Namespace: DevExpress.Xpf.Editors
Assembly: DevExpress.Xpf.Core.v24.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
editText | String | The editor’s text. |
cursorPosition | Int32 | The cursor (caret) position. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
selectionAnchor | Nullable<Int32> | null | The selection anchor. |
Remarks
The following code sample allows users to enter only Latin letters and capitalizes entered characters:
void OnCustomMask(object sender, DevExpress.Xpf.Editors.CustomMaskEventArgs e) {
if (e.ActionType == CustomTextMaskInputAction.Init || e.IsCanceled == true)
return;
var textInfo = CultureInfo.InvariantCulture.TextInfo;
if (!Regex.IsMatch(e.InsertedText, @"^[a-zA-Z]+$") && e.ActionType == CustomTextMaskInputAction.Insert)
e.Cancel();
else e.SetResult(textInfo.ToUpper(e.ResultEditText), e.ResultCursorPosition);
}
See Also