我在Windows窗体上有一个文本框。我想用分隔符设置最大值。 [英] I have a textbox on windows form. I want to set max value with a seperator.

查看:109
本文介绍了我在Windows窗体上有一个文本框。我想用分隔符设置最大值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Windows窗体上有一个文本框。那么值必须在[0..99999,999]的范围内!因此,不应该输入或接受值> 99999,999喜欢123456748!

此外只有1次十进制分隔符可用。



谢谢&此致,



我的尝试:



我试图设置最大值但最大长度但不能显示分隔符。

Hi,

I have a textbox on windows form. The Value must then be in the range [0..99999,999] !! Therefore it should not be possible to enter or accept a value > 99999,999 like 123456748 !
Moreover only 1 time Decimal Separator is possible.

Thanks & Regards,

What I have tried:

I tried to set the max value with max length but not able to show the separator .

推荐答案

为此,您应该自定义TextBox - 创建自己的myTextBox,它派生自TextBox。 />
在这个TextBox中你覆盖OnKeyPress-Method并根据你的要求进行增强。

例如你可以检查是否按下了有效的键,但是如果输入了字符串(它是value)不超过给定的限制。
For this you should customize your TextBox - create your own myTextBox which derives from TextBox.
In this TextBox you Override the OnKeyPress-Method and enhance it with your requirement.
For example could you check if a valid key is pressed, but also if the entered string (it's value) doesn't exceeds the given Limits.


这篇关于我在Windows窗体上有一个文本框。我想用分隔符设置最大值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆