string csz = "123"; //初始值
public Form1()
{
InitializeComponent();
textBox1.Text = csz;
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (textBox1.Text.IndexOf(csz) != 0)
{
textBox1.Undo();
}
}
private void textBox1_MouseUp(object sender, MouseEventArgs e)
{
if (textBox1.Text.IndexOf(csz) != 0)
{
textBox1.Undo();
}
}
温馨提示:答案为网友推荐,仅供参考