wpf-devexpress-dot-xpf-dot-editors-dot-custommaskeventargs-dot-setresult-x28-system-dot-string-system-dot-int32-system-dot-nullable-system-dot-int32-x29.md
Sets the editor text, cursor position, and selection anchor.
Namespace : DevExpress.Xpf.Editors
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
public void SetResult(
string editText,
int cursorPosition,
int? selectionAnchor = null
)
Public Sub SetResult(
editText As String,
cursorPosition As Integer,
selectionAnchor As Integer? = Nothing
)
| Name | Type | Description |
|---|---|---|
| editText | String |
The editor’s text.
| | cursorPosition | Int32 |
The cursor (caret) position.
|
| Name | Type | Default | Description |
|---|---|---|---|
| selectionAnchor | Nullable<Int32> | null |
The selection anchor.
|
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);
}
Private Sub OnCustomMask(ByVal sender As Object, ByVal e As DevExpress.Xpf.Editors.CustomMaskEventArgs)
If e.ActionType = CustomTextMaskInputAction.Init OrElse e.IsCanceled = True Then Return
Dim textInfo = CultureInfo.InvariantCulture.TextInfo
If Not Regex.IsMatch(e.InsertedText, "^[a-zA-Z]+$") AndAlso e.ActionType = CustomTextMaskInputAction.Insert Then
e.Cancel()
Else
e.SetResult(textInfo.ToUpper(e.ResultEditText), e.ResultCursorPosition)
End If
End Sub
See Also