当面板BackColor
从一种特定颜色变为另一种颜色时,我正试图触发一个事件。
当面板从绿色变为橙色时的伪示例。
If Panel.BackColor = Color.Green Changes To
Panel1.BackColor = Color.Orange
Then
Fire An Event
我知道您可以添加BackColorChanged
处理程序,但我不知道如何将这些特定颜色相互比较。
答案 0 :(得分:0)
你只需要在数组或列表中添加以前的颜色,甚至在字符串变量
中添加 Dim arr(1) As String
Private Sub Panel1_BackColorChanged(sender As Object, e As EventArgs) Handles Panel1.BackColorChanged
arr(0) = arr(1)
arr(1) = Panel1.BackColor.ToString
If arr(0) = "orange" And arr(1) = "green" Then
'do someting
End If
End Sub