使用IF检查图片框的图像位置值

问题描述 投票:0回答:1

为了让您知道,我正在使用visual basic winform编码。

我正在使用2015年的视觉工作室社区。

我知道如何使用这样的“if”命令:

If TextBox1.Text = "hi" Then
  Label1.Text = "TEST"
End If

我也知道我可以在里面装ifs ifs

If RadioButton1.Checked = True Then
  If Label1.Text = "hi" then
    Label2.Text = "TEST"
  End If
End If

但是当我尝试将它与picturebox一起使用时,它不起作用:

If PictureBox1.ImageLocation = "C:\blok\grass.png" Then
  Label1.Text = "TEST"
End If

当程序运行时,它会忽略它,是否有另一种方法可以执行此操作?

更新1.1

所以,为了让你知道,有人告诉我没有picturebox1.imagelocation,但如果是这样,那么这是如何工作的:

    if label1.text = "TEST" then
picturebox1.imagelocation = "C:\users\TEST\destop\TEST.png"
    end if

所以是的....这是第一次更新。也编辑这个我不得不重置我的密码,幸运的是我把它写下来所以我记得。

更新1.2

别担心,我想通了!它是这样的:

public class form1
dim IMAGE as integer = 1
private sub button1_click(sender As Object, e As EventArgs Handles)  button1.Click
if IMAGE = 1 then
picturebox1.imagelocation = "C:\TEST.png"
end if
end sub
end class
winforms picturebox
1个回答
0
投票
public class form1
dim IMAGE as integer = 1
private sub button1_click(sender As Object, e As EventArgs Handles) button1.Click
if IMAGE = 1 then
picturebox1.imagelocation = "C:\TEST.png"
end if
end sub
end class

通过这样做,当您单击按钮时,它将显示图片框。

© www.soinside.com 2019 - 2024. All rights reserved.