F
Firewalker
I am attempting to change the backColor property on the previously
instantiated buttons FROM a listbox_doubleClick event.
I thought it would be something like this:
If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then
Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue)
'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.item would essentially be
one of the buttons created.
I also tried this:
btn(iSeatNumber).backcolor.equals(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 lstSeatAvailable_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstSeatAvailable.DoubleClick
Select Case CStr(lstSeatAvailable.Items.Item(iSeatNumber))
Case CStr("Seat " & (iSeatNumber) & " is booked")
lstSeatAvailable.Items.Item(iSeatNumber) = "Seat " & (iSeatNumber) & " is
available"
'If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then
' Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue)
'End If
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Count - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Count
If Me.Controls.Item(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix1 = Nothing
ix2 = Nothing
Case CStr("Seat " & (iSeatNumber) & " is available")
lstSeatAvailable.Items.Item(iSeatNumber - 1) = "Seat " & (iSeatNumber) & "
is booked"
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Count - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Count
If Me.Controls.Item(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix1 = Nothing
ix2 = Nothing
'Implicitly set control white colored showing seat as booked
'Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White)
End Select
Dim ix3 As Integer
For ix3 = 0 To Me.Controls.Count - 1
If Me.Controls.Item(ix3).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix3 = Nothing
end sub
instantiated buttons FROM a listbox_doubleClick event.
I thought it would be something like this:
If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then
Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue)
'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.item would essentially be
one of the buttons created.
I also tried this:
btn(iSeatNumber).backcolor.equals(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 lstSeatAvailable_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstSeatAvailable.DoubleClick
Select Case CStr(lstSeatAvailable.Items.Item(iSeatNumber))
Case CStr("Seat " & (iSeatNumber) & " is booked")
lstSeatAvailable.Items.Item(iSeatNumber) = "Seat " & (iSeatNumber) & " is
available"
'If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then
' Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue)
'End If
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Count - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Count
If Me.Controls.Item(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix1 = Nothing
ix2 = Nothing
Case CStr("Seat " & (iSeatNumber) & " is available")
lstSeatAvailable.Items.Item(iSeatNumber - 1) = "Seat " & (iSeatNumber) & "
is booked"
Dim ix1 As Integer, ix2 As Integer
ix2 = Me.Controls.Count - 1 ' -1 to remove list box from iteration
For ix1 = 0 To Me.Controls.Count
If Me.Controls.Item(ix1).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix1 = Nothing
ix2 = Nothing
'Implicitly set control white colored showing seat as booked
'Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White)
End Select
Dim ix3 As Integer
For ix3 = 0 To Me.Controls.Count - 1
If Me.Controls.Item(ix3).Name = "btn" & iSeatNumber Then
btn.BackColor.Equals(Color.White)
End If
Next
ix3 = Nothing
end sub