I need for a user to be able to resize a panel using at least one corner at runtime. I did this by making a panel and placing a small picturebox in the bottom left corner. I'm only testing it, so I just gave both the picturebox and panel black borders so I could test my code. Here's what I came up with:
Yet when I try it, my panel flickers and the picturebox doesn't keep up with my cursor. Is there any easy way to revise my code? Thanks.Code:Public Class Form1 Dim isresize As Boolean = False Dim currentx As Integer Dim currenty As Integer Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown isresize = True currentx = e.X currenty = e.Y End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If isresize = True Then If e.X < currentx Then Panel1.Width = Panel1.Width - (currentx - e.X) currentx = e.X End If If e.X > currentx Then Panel1.Width = Panel1.Width + (e.X - currentx) currentx = e.X End If If e.Y < currenty Then Panel1.Height = Panel1.Height - (currenty - e.Y) currenty = e.Y End If If e.Y > currenty Then Panel1.Height = Panel1.Height + (e.Y - currenty) currenty = e.Y End If End If End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp isresize = False End Sub End Class




Reply With Quote