程序運行時智能增減控件
阿新 • • 發佈:2018-12-31
sharp class .sh this src amp else .com lse
實現效果:
知識運用:
Button控件的Visible屬性
Form窗體的Show方法和Hide方法
實現代碼:
Frm frm = new Frm(); private void button1_Click(object sender, EventArgs e) { if (txt_user.Text == "" || txt_pwd.Text == "") return; else if (txt_user.Text == "admin" && txt_pwd.Text == "admin") { frm.Text += " "+"登陸用戶:"+txt_user.Text; frm.Show(); this.Hide(); } else if (txt_user.Text == "user" && txt_pwd.Text == "user") { frm.Text += " " + "登陸用戶:" + txt_user.Text; frm.Show(); frm.button3.Visible = false; frm.button4.Visible = false; this.Hide(); } else { MessageBox.Show("用戶名或密碼輸有誤"); txt_user.Text = ""; txt_pwd.Text = ""; txt_user.Focus(); } }
程序運行時智能增減控件