Page 1 of 1

Unclickable Buttons

Posted: Sun Jul 27, 2008 6:34 am
by Eaton
You know how some buttons are unclickable and are grayed out until you open something? Then the button becomes clickable and an event happens. How can I make my button unclickable until a user opens a file in an OpenFileDialog?

Posted: Sun Jul 27, 2008 7:12 am
by NotZachary82
Enabled = false

Set that in the properties of the button.

Then you can try this:

Code: Select all

C#
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
     button1.Enabled = true;
}

Posted: Sun Jul 27, 2008 8:15 am
by Eaton
Ah, thank you! :)