古詩詞大全網 - 成語查詢 - c#密碼框中的*號 顯示密碼問題

c#密碼框中的*號 顯示密碼問題

用壹個復選框,然後兩個文本框疊放在壹起,textBox1是密碼框,textBox2是普通的文本框,加載時textBox2隱藏。

復選框選中,textBox1隱藏,textBox2顯示,把textBox1的值賦值給textBox2,否則反之。

private void Form1_Load(object sender, EventArgs e)

{

//加載時普通文本框隱藏

textBox2.Visible = false;

}

private void checkBox1_CheckedChanged(object sender, EventArgs e)

{

if (textBox2.Visible)

{

textBox1.Text = textBox2.Text;

}

else

{

textBox2.Text = textBox1.Text;

}

textBox2.Visible = checkBox1.Checked;

}