Enabling buttom from multiple combo selection

paulbacca

New member
Joined
Jan 25, 2008
Messages
4
Programming Experience
Beginner
Hi all,
I have 3 combo boxes each with a respective button. When a selection is made from the combo box, the button is enabled.

I have a forth button that i want to enable, but only when these 3 combo boxes have a selection. I have tried a few different ways to do this but with no success.

It seems that where to place the code is an issue as well as the way it check for these criteria.

any ideas?
Thanks
Paul
 
For example name the four buttons A B C and D. Put the letters A B and C in the corresponding combobox Tag property. Defining a flags enumeration allows for bitwise operations and is the best way to manage combinations of values.
VB.NET:
Expand Collapse Copy
<Flags()> Private Enum buttons
    none = 0
    A = 1
    B = 4
    C = 8
    all = A Or B Or C
End Enum

Private btnCombination As buttons

Private Sub combox(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ComboBox3.SelectedIndexChanged, ComboBox2.SelectedIndexChanged, ComboBox1.SelectedIndexChanged
    Dim abc As String = DirectCast(sender, Control).Tag
    Me.Controls(abc).Enabled = True
    btnCombination = btnCombination Or System.Enum.Parse(GetType(buttons), abc)
    If btnCombination = buttons.all Then
        D.Enabled = True
    End If
End Sub
 
Back
Top