CustomTextMaskInputArgs.Cancel() Method
In This Article
Cancels an edit a user attempts to perform.
Namespace: DevExpress.Data.Mask
Assembly: DevExpress.Data.v24.2.dll
NuGet Package: DevExpress.Data
#Declaration
#Remarks
The Cancel
method cannot be called if the ActionType returns “Init”.
The code sample below illustrates how to limit the maximum number of characters to 5.
protected override void ProcessCustomTextMaskInput(CustomTextMaskInputArgs args) {
if (args.IsCanceled || args.ResultEditText.Length < args.CurrentEditText.Length ||
args.ActionType == CustomTextMaskInputAction.Init || args.ResultEditText.Length <= 5)
return;
if (args.CurrentEditText.Length == 5 && args.CurrentSelectedText == String.Empty) {
args.Cancel();
return;
}
var maxInsertLength = 5 - args.CurrentHead.Length - args.CurrentTail.Length;
args.SetResult(args.CurrentHead + args.InsertedText.Substring(0, maxInsertLength), args.CurrentTail);
}
See Also