|
-
Mar 5th, 2004, 06:39 AM
#1
Thread Starter
Member
draw a line
if u draw a line,
anyidea how to rub it off (delete it)#
thank you very much
-
Mar 5th, 2004, 07:21 AM
#2
Depends what you are drawing on, if you are drawing on an image then you have to keep a copy of whatever was underneath.
If you are drawing onto a blank "canvas" so to speak then just use
picturebox1.CreateGraphics().Clear()
to revert the whole area to the default colour.
As soon as you draw the line, it becomes part of the image you drew it onto, it isn't a free floating object that can just be deleted easily.
I don't live here any more.
-
Mar 5th, 2004, 10:40 AM
#3
Thread Starter
Member
this is the code i used to draw a line over the main form
Dim MyPen As Pen = New Pen(Color.Red, 3)
Dim graphicsObject As Graphics = Me.CreateGraphics
graphicsObject.DrawLine(MyPen, Button1.Left + 23, Button1.Top + 12, Button1.Left + 35, Button1.Top + 12)
how I would be able to delete that,
thank you very much, have a nice day
-
Mar 5th, 2004, 03:41 PM
#4
Sleep mode
That's easy . Put 2 buttons :
1-Button1 = this clears the form .
2-Button2 = this draws on the form .
and paste this code . If you face any problem , post here .
This basically checks for the variable "clear" , and the trick is in "Me.Invalidate()" function which calls to redraw the form again in case it's invalid .
VB Code:
Private clear As Boolean = False
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
If clear Then
Dim MyPen As Pen = New Pen(Color.Red, 3)
Dim graphicsObject As Graphics = Me.CreateGraphics
graphicsObject.DrawLine(MyPen, 0, 0, Button1.Left + 35, Button1.Top + 12)
clear = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
clear = False
Me.Invalidate()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
clear = True
Me.Invalidate()
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|