mfc edit只允许输入数字
1、给EDIT控件添加 EN_CHANGE 事件
2、事件中的代码如下:
1 CString strEditVidoe;
2 GetDlgItem( iId )->GetWindowText( strEditVidoe );
3 // 只允许输数据
4 int nStringLength = strEditVidoe.GetLength();;
5 //
6 int nDotCount = 0;
7
8
9 // 点字符不能多于1个
10 //for ( int nIndex = 0; nIndex < nStringLength; nIndex++ )
11 //{
12 // if ( strEditVidoe[ nIndex ] == '.' )
13 // {
14 // nDotCount++;
15 // if ( nDotCount > 1 )
16 // {
17 // CString csTmp;
18 // csTmp = strEditVidoe.Left( nIndex );
19 // csTmp += strEditVidoe.Right( strEditVidoe.GetLength() - nIndex - 1 );
20 // //csRadius = csRadius.Left( nIndex + 1 ) + csRadius.Right( nStringLength - ( nIndex + 1 ) - 1 );
21 // GetDlgItem( iId)->SetWindowText( csTmp );
22 // return;
23 // }
24 // }
25 //} strEditVidoe[ nIndexm ] != '.' &&
26
27 // 不允许输入数字以外的字符
28 for ( int nIndexm = 0; nIndexm < nStringLength; nIndexm++ )
29 {
30 if ( ( strEditVidoe[ nIndexm ] > '9' || strEditVidoe[ nIndexm ] < '0' ) )
31 {
32 strEditVidoe = strEditVidoe.Left( nIndexm ) + strEditVidoe.Right( strEditVidoe.GetLength() - nIndexm - 1 );
33 GetDlgItem( iId )->SetWindowText( strEditVidoe );
34 return 0;
35 }
36 }
37 return 0;
mfc edit只允许输入数字的更多相关文章
- js控制只允许输入数字
avascript 只允许输入数字有很多方法,总结如下 1,只允许输入数字和小数点. <input onKeypress="return (/[\d.]/.test(String.fr ...
- c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字
TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和Ctrl+v private void txtNumber_KeyPress( ...
- javascript限制input只允许输入数字
在做数据提交的表单时,经常要对input输入内容的类型进行限制,譬如javascript限制input只允许输入数字,最好的方法当然是使用javascript,因为它不用与服务器交互,大大减轻了服务器 ...
- ASP.Net TextBox控件只允许输入数字
原文:ASP.Net TextBox控件只允许输入数字 1.1.在Asp.Net TextBox 控件的 OnKeyPress 事件中指定输入键盘码必须为数字: <asp:TextBox ID= ...
- WinForm笔记一:文本框只允许输入数字
在WinForm的文本框中,有时候只允许数字,而不能输入除数字以外的其他字符,要调用TextBox的KeyPress事件,代码如下: //只允许输入数字 if (e.KeyChar<'0'||e ...
- input输入框只允许输入数字/ 数字+小数点/ 文字+字母/ 等解决方法
1.只允许输入数字: <input type="text" onkeyup="this.value=this.value.replace(/[^0-9]/g,'') ...
- 限制TextBox只允许输入数字和字母
设置TextBox控件属性 ImeMode=Disable ShortcutsEnabled=False VB.NET Private Sub TextBox1_KeyDown(sender As O ...
- 2019-3-22c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字
TextBox 禁止复制粘贴 ShortcutsEnabled =false TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和 ...
- input输入限制,只允许输入数字和“.”,长度不得超过20
<input style="margin-top: 10px;width: 100%;text-align:center;" id="removeArea" ...
- js只允许输入数字和两位小数
一.js只允许输入数字和两位小数 //只允许输入数字和两位小数 function clearNoNum(obj) { obj.value = obj.value.replace(/[^\d.]/g, ...
随机推荐
- web server 接口调用
1. 生成客户端代码 2.调用接口 import javax.xml.ws.Service;public static NotificationServiceDevImplPortType mokaA ...
- JS篇(005)-== 和 === 的不同
答案:==是抽象相等运算符,而===是严格相等运算符.==运算符是在进行必要的类型转换后,再比较.===运算符不会进行类型转换,所以如果两个值不是相同的类型,会直接返回false.使用==时,可能发生 ...
- labwindows/cvi activex 控件无法正常使用问题解决
在进行labwindows/cvi编程时,想使用时间控件,需要在界面上点击右键的activex选项中选择Microsoft Data and Time picker control6.0(SP4).如 ...
- element的el-table合计显示不出来
在updated中写入 this.$nextTick(() => { this.$refs["printStatisticsTableData"].doLayout(); } ...
- 「SOL」NOI2017Day2 T1T2
就当我没做过这套题 而且 T3 也不会 Day2 A. 游戏 > Link 游戏 - LOJ 做过 2-sat 的读者应该能够一眼秒出这道题的正解 -- \(\mathcal O(2^d)\) ...
- B - WeirdSort
B - WeirdSort 思路:经过认真的审题,你会发现,这只是个冒泡的变形,我们建立两个数组,然后用一个数组里面的数字确定位置,然后冒泡就行了.最后抖机灵用了个is_sorted,判断数组里面数字 ...
- node中get和post接口
接口传参 使用ajax请求向服务器接口传参,按http协议的约定,每个请求都有三个部分: 请求行: 保存了请求方式,地址,可以以查询字符串的格式附加一部分数据. 请求头:它可以附加很多信息,其中con ...
- 汇编debug工具Dosbox使用
汇编debug工具DOSBOX使用说明 首先新建文件,更改后缀名为asm,然后写入一段汇编程序 之后打开DosBox 输入masm + 文件名(加不加文件名后缀都可以)但如果要加的话,应该加上. ...
- 基于uniapp框架开发飞书小程序总结
前期准备 飞书官方客户端文档:https://open.feishu.cn/document/home/intro 飞书官方工具资源文档:https://open.feishu.cn/document ...
- SQL-while begin end
declare @i int set @i=1 while @i<=10000000begin insert into dbo.Persons (Age,Sex,Grade,Name) valu ...