C++/CLI登陆对话框编程疏失
C++/CLI登陆对话框编程出错
String^ regstr = L"^\w+$";
Regex^ reg = gcnew Regex(regstr);
if(this->txtName->Text != "")
{
if(reg->IsMatch(this->txtName->Text))
{
e->Handled = false;
}
else
{
MessageBox::Show(L"用户名只能为字母、数字和下划线!");
e->Handled = true;
}
对话框只能输入一个字母,第二个字母输入后会执行 MessageBox::Show(L"用户名只能为字母、数字和下划线!");
------解决方案--------------------
String^ regstr = L"^\\w+$";
String^ regstr = L"^\w+$";
Regex^ reg = gcnew Regex(regstr);
if(this->txtName->Text != "")
{
if(reg->IsMatch(this->txtName->Text))
{
e->Handled = false;
}
else
{
MessageBox::Show(L"用户名只能为字母、数字和下划线!");
e->Handled = true;
}
对话框只能输入一个字母,第二个字母输入后会执行 MessageBox::Show(L"用户名只能为字母、数字和下划线!");
c++/cli
RegEx
对话框
------解决方案--------------------
String^ regstr = L"^\\w+$";