Timer Control for PictureBox created during runtime - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Timer Control for PictureBox created during runtime

LuvKnightLuvKnight Posts: 1Member
[code]Public Function NewApple()
Dim picNewApple As PictureBox = New PictureBox()
Dim AppleType As Integer = RandomNumber(100)
If AppleType >= 75 Then
picNewApple.Image = Image.FromFile(Application.StartupPath & "RedApple.gif")
ElseIf AppleType >= 50 Then
picNewApple.Image = Image.FromFile(Application.StartupPath & "GreenApple.gif")
ElseIf AppleType >= 25 Then
picNewApple.Image = Image.FromFile(Application.StartupPath & "GoldApple.gif")
ElseIf AppleType >= 0 Then
picNewApple.Image = Image.FromFile(Application.StartupPath & "WormApple.gif")
End If
picNewApple.Location = New System.Drawing.Point(RandomNumber(600), 5)
picNewApple.SizeMode = PictureBoxSizeMode.AutoSize
picNewApple.BackColor = Color.Transparent
Me.Controls.Add(picNewApple)
End Function
[/code]
I've this, is there anyway I could control the picturebox using a new event? This would be in a 1 second timer when a new apples comes out every second. Now I need to be able to control it location after it's added to the form by using the .Left

Hope someone understands me.

Sign In or Register to comment.