CGridCtrlEx表格及限制表格输入数字和‘.’

it2024-07-14  74

CGridCtrlEx m_Grid; BOOL CDlgFillinTable::SetContentsByNumericCol() { CCellID currentCell = m_Grid.GetFocusCell(); CString strContents = m_Grid.GetItemText(currentCell.row,currentCell.col); if(strContents.IsEmpty()) return TRUE; CString strText; if (m_iSWeightNum == currentCell.col || m_iTWeightNum == currentCell.col || m_iCountNum == currentCell.col) { for(int i=0 ; i<strContents.GetLength() ; i++) { if(strContents.GetAt(i) < 46 || strContents.GetAt(i) > 57 || strContents.GetAt(i) == 47) { m_Grid.SetItemText(currentCell.row,currentCell.col,m_strContents); break; } } if ( 1<strContents.Replace(_T("\."),_T("\.")) || 46==strContents.GetAt(0) )//strContents.Find(_T("\."),0); { m_Grid.SetItemText(currentCell.row,currentCell.col,m_strContents); } } return TRUE; }
最新回复(0)