Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.2.dll

NuGet Package: DevExpress.Wpf.Core

#Declaration

public void SetResult(
    string editText,
    int cursorPosition,
    int? selectionAnchor = null
)

#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