开发者

How do I set a max numeric value in a Devexpress TextEdit box?

I've got a numbers-only TextEdit box with MaxLength set to 2, allowing the user to enter 0-99. Can I restrict this to a smaller range, say 0-30, without catching the TextChanged event, validating the input and showing a messsag开发者_StackOverflow中文版e (or similar method)?


You should use the SpinEdit control and set the max and min properties.


You could set the regexp mask to \d|[0-2]\d|30.


Handle the EditValueChanging event,

private void txtQuantity_EditValueChanging(object sender, ChangingEventArgs e)
{
    var value = Convert.ToDouble(e.NewValue);
    if (value < MIN || value > MAX) e.Cancel = true;
}


In winforms you should use System.Windows.Forms.NumericUpDown and set the Maximum and Minimum properties.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜