我正在用 Visual C++ 编写一个程序,我需要测试 TextBox 是否为空。例如(伪代码):
if ( textBox is empty ) {
// etc..
}
如何测试这种情况?
if(string.isNullOrEmpty(textbox.text)){//Your code Here}
大概是这样的。
如果你直接使用 Win32 那么它是这样的:
if ( SendMessage( hWndTextBox, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{
}
如果是MFC,那么:
if ( textBox.GetWindowTextLength() == 0 )
{
}
if (String::IsNullOrEmpty(textBox1->Text) && String::IsNullOrEmpty(textBox2->Text)) 这检查文本框是否为空