textbox提示

        private void textBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (textBox1.Text.Equals(textBoxNotice))
            {
                this.textBox1.ForeColor = Color.Black;
                textBox1.Text = "";
            }
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (textBox1.Text.Length == 0)
            {
                this.textBox1.ForeColor = SystemColors.ScrollBar;
                textBox1.Text = textBoxNotice;
            }
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (textBox1.Text.Contains(textBoxNotice))
            {
                this.textBox1.ForeColor = Color.Black;
                textBox1.Text = textBox1.Text.Replace(textBoxNotice, "");
            }
        }

 

上一篇:C#实现转换十六进制


下一篇:WPF中textbox加入文件拖放操作