本文介绍了仅允许在文本框中写入10的倍数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个文本框只能接受10到100的10的倍数

One of my textbox must only accept multiple of 10 from 10 to 100

我已经考虑了最小值和最大值,但我不知道如何只允许使用
{10,20,30,40,50,60,70,80,90 and 100}要写.

实际上,可以写入任何数字,但是在写入无效数字时会弹出错误消息.

该消息已经很好,但是如何使其具有此约束?

谢谢

I already took care of the minimum and maximum value but I don't know how to only allow
{10, 20, 30, 40, 50, 60, 70, 80, 90 and 100} to be written.

Actually, any numbers could be written but and error message most pop when and invalid number is written.

The message is already good but how do I make it appear with this constraint ?

Thank you

推荐答案

我认为这是某种家庭作业,所以我只给出一个提示:

I assume this is some kind of homework, so I'll only give a hint:

使用Validating事件,在方法中使用Modulo运算符.

Use the Validating event and in the method use the Modulo operator.

https://msdn.microsoft.com/zh-cn/library/system.windows.forms.control.validating(v = vs.110).aspx?f = 255& MSPPError = -2147217396

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating(v=vs.110).aspx?f=255&MSPPError=-2147217396

https://msdn.microsoft.com/zh-CN/library/se0w9esz.aspx

https://msdn.microsoft.com/en-us/library/se0w9esz.aspx

此致

  Thorsten

  Thorsten


这篇关于仅允许在文本框中写入10的倍数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:20