【发布时间】:2013-06-09 08:53:03
【问题描述】:
我正在尝试检查我的 panel0.background 图像是否与资源中的图像相同,然后将一些字符串添加到 arraylist。
这似乎不起作用:
If (Panel0.BackgroundImage Is My.Resources.Dinoback) Or (Panel0.BackgroundImage Is My.Resources.Dinoback2) Then
Form1.jenisbuddyarr.Add("dino")
ElseIf (Panel0.BackgroundImage Is My.Resources.Rabbitback) Or (Panel0.BackgroundImage Is My.Resources.Rabbitback2) Then
Form1.jenisbuddyarr.Add("rabbit")
ElseIf (Panel0.BackgroundImage Is My.Resources.Squirrelback) Or (Panel0.BackgroundImage Is My.Resources.Squirrelback2) Then
Form1.jenisbuddyarr.Add("squirrel")
End If
【问题讨论】:
-
对,这行不通,因为每次在代码中使用 My.Resources.Foo 时,都会得到一个 new 图像对象。您需要在表单中添加 Image 类型的变量,并在表单构造函数中只分配一次。或者使用单独的变量跟踪面板中的内容。