在一定时间 VB.Net 后更改图片框可见性



我目前将它更改为 picturebox1 在加载时可见的位置,我想将其更改为 picturebox2 可见且 picturebox1 在 3 秒后不可见的位置。我一直无法让它明显起作用。有什么建议吗?我环顾四周,看到了Picturebox.refresh和picturebox.update,但无法让它们工作。我也愿意接受有关如何以不同方式执行此操作的建议。感谢您的帮助!

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.BackgroundImage = My.Resources.Resources._024689
PictureBox2.BackgroundImage = My.Resources.Resources._152522206296244269
PictureBox1.Visible = True
PictureBox2.Visible = False
InitializeComponent()
'starts timer
StartTimer.Interval = 1000
StartTimer.Start()
End Sub
Private Sub StartTimer_Tick(sender As Object, e As EventArgs) Handles StartTimer.Tick
time += 1
Debug.Print("Time = " & time)
If time = 3 Then
PictureBox2.Visible = True
PictureBox1.Visible = False
StartTimer.Stop()
End If
End Sub

根据记录,这完全符合预期:

'Ensure that resources are loaded once only.
Private ReadOnly firstImage As Image = My.Resources.Capture__56x81_
Private ReadOnly secondImage As Image = My.Resources.Capture__70x264_
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = firstImage
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Stop()
PictureBox1.Image = secondImage
End Sub

请注意,设计器中的Timer1Interval设置为 3000。

最新更新