Last Updated: February 25, 2016
·
1.401K
· hjwu

How to avoid input negative number on DevExpress.TextEdit

This is an example to show how to keep numeric type but do not allow input negative number.

DevExpress.XtraEditors.TextEdit te = new TextEdit();
te.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
te.Properties.Mask.EditMask = "n2";

te.EditValueChanging += (s, e) => 
{ 
    e.Cancel = e.NewValue.ToString().Contains("-"); 
};