C#Winフォームのデフォルトのメッセージテキストボックス

プライベート文字列注意=「プロンプトテキスト」;
プライベートボイドtextBox1_Leave(オブジェクト送信者、EventArgsの電子)
{
    //終了し、フォーカス、再表示を失います
    もし(string.IsNullOrEmpty(textBox1.Text))
    {
        textBox1.ForeColor = Color.DarkGray。
        this.textBox1.Text =注;
    }
}

プライベートボイドtextBox1_Enter(オブジェクト送信者、EventArgsの電子)
{
    //フォーカス、クリアに
    もし(textBox1.Text ==注意事項)
    {
        textBox1.ForeColor = Color.Black。
        this.textBox1.Text = "";
    }
}

  

おすすめ

転載: www.cnblogs.com/baissy/p/11724042.html