I am attempting to change the backColor property on the previously
instantiated buttons FROM a listbox_doubleC lick event.
I thought it would be something like this:
If Me.Controls.Ite m(iSeatNumber). BackColor.Equal s(Color.White) Then
Me.Controls.Ite m(iSeatNumber). BackColor.Equal s(Color.Cornflo werBlue)
'End If
Just as an FYI, there are 100 buttons on my form and they were instantiated
at run time.
iSeatNumber would be an integer and me.controls.ite m would essentially be
one of the buttons created.
I also tried this:
btn(iSeatNumber ).backcolor.equ als(Color.White )
but intellisense says that the button cannot be accessed because it has no
default property. Could it be that I need to pass the buttons object to the
doubleClick event?
Any ideas on this would help a lot!
Bob
My code as follows:
Private Sub lstSeatAvailabl e_DoubleClick(B yVal sender As Object, ByVal e As
System.EventArg s) Handles lstSeatAvailabl e.DoubleClick
Select Case CStr(lstSeatAva ilable.Items.It em(iSeatNumber) )
Case CStr("Seat " & (iSeatNumber) & " is booked")
lstSeatAvailabl e.Items.Item(iS eatNumber) = "Seat " & (iSeatNumber) & " is
available"
'If Me.Controls.Ite m(iSeatNumber). BackColor.Equal s(Color.White) Then
' Me.Controls.Ite m(iSeatNumber). BackColor.Equal s(Color.Cornflo werBlue)
'End If
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Cou nt - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Cou nt
If Me.Controls.Ite m(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.E quals(Color.Whi te)
End If
Next
ix1 = Nothing
ix2 = Nothing
Case CStr("Seat " & (iSeatNumber) & " is available")
lstSeatAvailabl e.Items.Item(iS eatNumber - 1) = "Seat " & (iSeatNumber) & "
is booked"
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Cou nt - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Cou nt
If Me.Controls.Ite m(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.E quals(Color.Whi te)
End If
Next
ix1 = Nothing
ix2 = Nothing
'Implicitly set control white colored showing seat as booked
'Me.Controls.It em(iSeatNumber) .BackColor.Equa ls(Color.White)
End Select
Dim ix3 As Integer
For ix3 = 0 To Me.Controls.Cou nt - 1
If Me.Controls.Ite m(ix3).Name = "btn" & iSeatNumber Then
btn.BackColor.E quals(Color.Whi te)
End If
Next
ix3 = Nothing
end sub