时间检查器中的文本字段 [英] text field in time checker

查看:59
本文介绍了时间检查器中的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我在用户输入信息时如何检查文本字段的数据类型.例如,如果我希望在文本字段中输入int并且用户输入"fgze",则我想显示一个标签,告诉他期望有一个整数.

解决方案

控制keydown事件,如果不允许使用引入的字符,则显示标签.

注意:您可以在对话框编辑器中右键单击该元素并设置正确的属性来为editbox添加事件.

您应该根据所按下的键来放弃该事件...

也就是说,如果按下数字,则应该正常处理它,但是如果它是字母或任何其他东西,则应该中断消息的执行.

HTH.


[添加到Joan的答案]

您还可以使用特定于数据类型的控件.例如,用于时间的日期时间控件,用于整数的数字文本框,用于货币的掩码文本框,用于IP地址的IP地址控件等.


使用样式ES_NUMBER. /blockquote>

can someone tell me how to check the data type of a text field while the user is entring information. for example, if I am expecting an int in a text field and the user enters "fgze", I want to display a lable that tell him an integer is expected.

解决方案

Control the keydown event and show the label if the char introduced is not something allowed.

Note: You can add the event for the editbox in the dialog editor right clicking the element and setting the right properties.

You should discard the event depending on the key that has been pressed...

i.e. if a number is pressed you should process it normally, but if it is a letter or any other thing, then you should break the message execution.

HTH.


[Adding to Joan''s answer]

You can also use controls specific to the data type. Example a date-time control for time, a numeric textbox for integers, a masked text box for currency, an IP address control for IP addresses etc.


Use the style ES_NUMBER.


这篇关于时间检查器中的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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