Reputation:
I am trying to make buttons only visible when a password is entered correctly. This is a WindowsFormApplcation..
So the part I am working on is a submit button the user clicks after typing in the password
private void button3_Click(object sender, EventArgs e)
{
if ( textBox1.Text == "password")
}
Now the buttons I want to show are already their just set to hidden, and their names are button1 and button 2. I am a c# begginer and working my way through the basics. Thanks Chris
Upvotes: 1
Views: 1290
Reputation: 53593
By 'hidden' I assume you mean their Visible property is set to false.
To show them, set their Visible property to true, like so:
if ( textBox1.Text == "password") {
button1.Visible = true;
button2.Visible = true;
}
Does this help?
Upvotes: 2
Reputation: 1398
Another possibility is to put both buttons as visible, and add them to a panel container control. Set the panel control to Visibility = false, and just change the panel container to Visibility = true;
tip: [ctrl]+[alt]+[x] is keyboard shortcut for showing/hiding the toolbox, container controls are all grouped together.
Use the same password check/visibility change as mentioned by Jay's comment.
Upvotes: 1