Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Reseting Combo Box

Greyham29Greyham29 Posts: 1Member
Hey guys
I am busy with a project at the moment which I am very excited about but I have got stuck and for the life of me I cannot figure out how to solve my problem. Let me explain:
I have 8 Picture Box's and under each Pic Box I have a Combo Box. Now, lets say, for example, that the user picks a colour from these Combo Box's and then the relevant Pic Box changes to display that colour. Now, there is a limit to how many of a certain colour the user can choose. For eg: The user can only select yellow 4 times.
What I would like is that when the user chooses yellow for the 5th time the combo box and relevant pic box that he used to select it to be reset to what it was ie. Pic box goes back to default aswell as the combo box. Just typing it here I know there is a easy solution but I just cant think of it.
Thanks for any help

G

Comments

  • Bill25Bill25 Posts: 51Member
    : Hey guys
    : I am busy with a project at the moment which I am very excited about but I have got stuck and for the life of me I cannot figure out how to solve my problem. Let me explain:
    : I have 8 Picture Box's and under each Pic Box I have a Combo Box. Now, lets say, for example, that the user picks a colour from these Combo Box's and then the relevant Pic Box changes to display that colour. Now, there is a limit to how many of a certain colour the user can choose. For eg: The user can only select yellow 4 times.
    : What I would like is that when the user chooses yellow for the 5th time the combo box and relevant pic box that he used to select it to be reset to what it was ie. Pic box goes back to default aswell as the combo box. Just typing it here I know there is a easy solution but I just cant think of it.
    : Thanks for any help
    :
    : G
    :

    ---

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If CheckYellow = False Then
    ComboBox1.SelectedIndexChanged = - 1
    Picture1.BackColor = Color.White*
    '* I guess you are using the BackColor of the PictureBox and I '* use the White color as default
    End If
    End Sub

    Function CheckYellow() As Boolean
    Dim CountYellow As Integer = 0
    ' check the index where yellow appears
    If Combobox1.SelectedIndex = 1 Then CountYellow += 1
    If Combobox2.SelectedIndex = 1 Then CountYellow += 1
    If Combobox3.SelectedIndex = 1 Then CountYellow += 1
    If Combobox4.SelectedIndex = 1 Then CountYellow += 1
    If Combobox5.SelectedIndex = 1 Then CountYellow += 1
    If Combobox6.SelectedIndex = 1 Then CountYellow += 1
    If Combobox7.SelectedIndex = 1 Then CountYellow += 1
    If Combobox8.SelectedIndex = 1 Then CountYellow += 1
    ' or check for word "yellow"
    If Combobox1.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox2.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox3.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox4.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox5.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox6.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox7.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    If Combobox8.SelectedItem.ToString = "Yellow" Then CountYellow += 1
    ' Return true or false
    If CountYellow <= 4 Then Return True Else Return False
    End Function


Sign In or Register to comment.