Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Combobox unhandled exception

$
0
0
I made a combobox for the user to select a style for the application. When I test it by selecting each index I get an unhandled exception, what should I look at doing in order to fix this. What is wrong with what I am doing.

Code:

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        'Resets the background after each 'selectionIndexChanged' event
        If Not Me.BackColor = SystemColors.Control Then
            Me.BackColor = SystemColors.Control
        End If
        'Resets the background after each 'selectionIndexChanged' event
        If Not IsNothing(Me.BackgroundImage) Then
            Me.BackgroundImage.Dispose()
        End If

        Dim combo_se_style As Integer = ComboBox2.SelectedIndex
        'Yellow - Green - Orange - Blue - Pink (0-4)
        'Ice - Fire - Retro - Sky - Dark (5-9)

        Select Case combo_se_style
            Case 0
                Me.BackColor = Color.Yellow
            Case 1
                Me.BackColor = Color.LightSeaGreen
            Case 2
                Me.BackColor = Color.Orchid
            Case 3
                Me.BackColor = Color.DeepSkyBlue
            Case 4
                Me.BackColor = Color.LightSalmon
            Case 5
                Me.BackgroundImage = My.Resources.Ice1
            Case 6
                Me.BackgroundImage = My.Resources.Fire
            Case 7
                Me.BackgroundImage = My.Resources.Retro
            Case 8
                Me.BackgroundImage = My.Resources.Sky
            Case 9
                Me.BackgroundImage = My.Resources.Dark
        End Select
    End Sub


Viewing all articles
Browse latest Browse all 42220

Trending Articles