hi,
I've moving image using keyboard, and i want to make this image bound to my form. I mean i don't want to let my image away from the form boundaries. I did it in VB 6 but don't know how to do it in VB.Net, Can anyone please tell me?
thanks..
Printable View
hi,
I've moving image using keyboard, and i want to make this image bound to my form. I mean i don't want to let my image away from the form boundaries. I did it in VB 6 but don't know how to do it in VB.Net, Can anyone please tell me?
thanks..
how do you mean "bound to my form"?
if you mean the picturebox must remain within your form's clientrectangle:
vb Code:
Public Class Form1 Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown Dim r As Rectangle Select Case e.KeyCode Case Keys.Left r = New Rectangle(PictureBox1.Left - 10, PictureBox1.Top, 50, 50) Case Keys.Right r = New Rectangle(PictureBox1.Left + 10, PictureBox1.Top, 50, 50) Case Keys.Up r = New Rectangle(PictureBox1.Left, PictureBox1.Top - 10, 50, 50) Case Keys.Down r = New Rectangle(PictureBox1.Left, PictureBox1.Top + 10, 50, 50) End Select If Me.ClientRectangle.Contains(r) Then PictureBox1.Bounds = r End If End Sub End Class