void CSettingcategory::OnEnChangeEdit2()
{CString csAreaS;GetDlgItem( IDC_EDIT2 )->GetWindowText( csAreaS );// 只允许输数据int nStringLength = csAreaS.GetLength();int nDotCount = 0;// 点字符不能多于1个for ( int nIndex = 0; nIndex < nStringLength; nIndex++ ){if ( csAreaS[ nIndex ] == '.' ){nDotCount++;if ( nDotCount > 1 ){CString csTmp;csTmp = csAreaS.Left( nIndex );csTmp += csAreaS.Right( csAreaS.GetLength() - nIndex - 1 );//csRadius = csRadius.Left( nIndex + 1 ) + csRadius.Right( nStringLength - ( nIndex + 1 ) - 1 );GetDlgItem( IDC_EDIT2 )->SetWindowText( csTmp );return;}}}// 不允许输入数字和点以外的字符for ( int nIndex = 0; nIndex < nStringLength; nIndex++ ){if ( csAreaS[ nIndex ] != '.' && ( csAreaS[ nIndex ] > '9' || csAreaS[ nIndex ] < '0' ) ){csAreaS = csAreaS.Left( nIndex ) + csAreaS.Right( csAreaS.GetLength() - nIndex - 1 );GetDlgItem( IDC_EDIT2 )->SetWindowText( csAreaS );return;}}
}
详细解决方案
[VC++]限制CEdit(Edit Contrl)只能输入数字和小数点
热度:50 发布时间:2024-01-04 04:32:54.0
相关解决方案
- 怎样动态为GridView添加Select、Edit、Delete按钮,该如何解决
- rowcommand 与 edit,该怎么解决
- SVN的Not authorized to open root of edit operation解决方法
- 做Rich Text Edit Box 是不是一般都用的iframe,该怎么解决
- jQuery jqGrid inline edit 回车之后新增有关问题
- MyEclipse + Weblogic 8g 次次 debug 时要求 Edit Source Lookup Path 添加被调试项目的解决方案
- edit plus打开jsp文件,汉字乱码有关问题
- edit.format 小数位数设置解决方案
- PB11.5省略显示属性(edit.useellipsis=yes)如何判断到是省略状态
- Edit Control控件不接受\n换行吗?解决办法
- CMFCEditBrowseCtrl CEdit 文本编辑控件
- Android studio edit view 边框显示,inputType
- CEdit 控件 更新内容的 方法(可以自动滚动至末尾)
- edit control
- C++/MFC-Edit
- 3.MFC中的CListCtrl,CComboBox,CEdit,CTabCtrl
- [VC++]限制CEdit(Edit Contrl)只能输入数字和小数点
- quicktime player edit video
- ENTER Key change the focus of Edit Controls
- windows程序设计编辑类 edit
- CEdit 背景色设置