1.定义
public: bool isModelText;//设置全局变量
2.设置TextBox事件
//窗口Load事件
System::Void InfoDeal::InfoDeal_Load(System::Object^ sender, System::EventArgs^ e)
{
isModelText = false;
this->tb_ZHZPath->Text = L"请选择文件夹……";//默认设置
}
//TextBox Enter事件
System::Void InfoDeal::tb_Path_Enter(System::Object^ sender, System::EventArgs^ e)
{
if(!isModelText)
{
this->tb_NCPath->Text = L"";
}
this->tb_NCPath->ForeColor = Color::Black;
}
//TextBox Leave事件
System::Void InfoDeal::tb_Path_Leave(System::Object^ sender, System::EventArgs^ e)
{
if(this->tb_NCPath->Text == "")
{
this->tb_NCPath->Text = L"请选择文件夹……";
this->tb_NCPath->ForeColor = Color::LightGray;
isModelText = false;
}
else
isModelText = true;
}