Problem with MaskedTextBox with such mask ([\-\+])?0x([A-Fa-f0-9]*)

Editors for WPF Forum

Posted 10 years ago by Ruslan Fedoseienko
Version: 14.2.0610

I have a MaskedTextBox with such mask ([\-\+])?0x([A-Fa-f0-9]*).

It is a mask for relative offset i.e. +0x16 mean currentOffset+=0x16 and i want it to support normal offsets i.e 0x42

I want to disable posibility of deletion 0x part of mask for this purposies I've added such TextChanging handler

private void OnTextChanging(object sender, StringPropertyChangingRoutedEventArgs e)
	e.Cancel = !(GoToModel.DistanceRegex.IsMatch(e.NewValue));

 where GoToModel.DistanceRegex is System.Text.RegularExpressions.Regex.

The problem:

0x is enterd by default. When user prepend + it becomes imposible to delete it because e.NewValue is empty string. I expect it to be "0x".

Is it a bug? Is there any workaround?

[Modified 10 years ago]

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA

Hello, I believe it's due to the regex parser.  If you put a whitespace before and after the "0x" portion of your mask, the regex parser will pull out the parts correctly.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.