Visual Studio 2010 Newbie Question (C#)?

Blkhart

New member
Joined
May 7, 2010
Messages
3
Reaction score
0
Points
1
I have my screen looking like this: http://tinypic.com/r/14lm0j5/7

I've set it up so that the "Open" Button becomes enabled when the "Browse..." button is clicked.

My problem is this, I have my code set up like so:

private void OpenFileBrowseButton_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.ShowDialog();
OpenFileOpenButton.Enabled = true;

private void OpenFileForm_Load(object sender, EventArgs e)
{
OpenFileOpenButton.Enabled = false;
}

With how it is now the "Open" button remains enabled until the window closes once the "Browse..." button is clicked. I need it to where the "Open" button will not be enable so long as the ComboBox does not have text in it. How do I do this with my code?
 
not quite sure what you mean, but if you don't want the Open button to be enabled if there are no items in the combo, then just put


private void OpenFileBrowseButton_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.ShowDialog();

if (comboBox1.Items.Count > 0)
{
OpenFileOpenButton.Enabled = true;
}

this way, it will only be enabled if there are items in the combo box
 
Back
Top