Resizing Rectangle

Hi i draw some rectangle on a picturebox image. Now can i resize that rectangle by dragging the border of the rectangle.
my code is
======

Private Sub picTest_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picTest.MouseDown
m_drawing = True
X1 = e.X
X2 = e.X
Y1 = e.Y
Y2 = e.Y
grImage = picTest.CreateGraphics()
End Sub
Private Sub picTest_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picTest.MouseMove
If m_drawing Then
X2 = e.X
Y2 = e.Y
End If
End Sub

Private Sub picTest_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picTest.MouseUp
If X1 = X2 And Y1 = Y2 Then Exit Sub
Dim rect As New Rectangle(Min(X1, X2), Min(Y1, Y2), Abs(X1 - X2), Abs(Y1 - Y2))
grImage.DrawRectangle(Pens.Red, rect)

m_drawing = False
cnt = cnt + 1
grImage.DrawString(cnt, New Font("Verdana", 10), Brushes.Blue, Min(X1, X2), Min(Y1, Y2))
Dim dr As DataRow
dr = dt.NewRow

dr.Item(0) = Y1
dr.Item(1) = X1
dr.Item(2) = Max(X2, X1) - Min(X1, X2)
dr.Item(3) = Max(Y2, Y1) - Min(Y1, Y2)
dt.Rows.Add(dr)
DataGrid1.DataSource = ds.Tables(0)

'----

'----

End Sub

======
[1589 byte] By [kohlimannu] at [2007-11-19 14:08:44]
# 1 Re: Resizing Rectangle
Maybe this thread will help you (If I understood your question correctly):

http://www.dev-archive.com/forum/showthread.php?t=356995&highlight=deltax

This will show you how to resize a TextBox when the mouse is draged over the border (left and right). If this is what you need then you can easily replace the textbox with a picturebox and implement an up-down resize.
jhammer at 2007-11-10 3:16:02 >
# 2 Re: Resizing Rectangle
Maybe this thread will help you (If I understood your question correctly):

http://www.dev-archive.com/forum/showthread.php?t=356995&highlight=deltax

This will show you how to resize a TextBox when the mouse is draged over the border (left and right). If this is what you need then you can easily replace the textbox with a picturebox and implement an up-down resize.
Actually i need to move and resize the rectangle which ive darwn on the image not the image.
kohlimannu at 2007-11-10 3:17:10 >