Good morning/ afternoon to all of you ..
it's the first time for me to be here ..!!
my english may seems bad hhhhhh
but anyway , i like programming and i'm studying some programming language ..
i'm trying to do taskes in VB.Net but i faced difficulty..
if u can help me i'll appraciate ur help ..
This is the question
i'll post what i have write
but whenever i run the form it gives me an error on that part
and i don't know how to clear the picbox after drowing and how to change the size of drowing..!!
i know i'm asking alot but i want to learn
Thanks in advance
it's the first time for me to be here ..!!
my english may seems bad hhhhhh
but anyway , i like programming and i'm studying some programming language ..
i'm trying to do taskes in VB.Net but i faced difficulty..
if u can help me i'll appraciate ur help ..
This is the question
Write a program that allows the user to draw 'free-hand' images with the mouse in a PictureBox. Be sure to provide the following:
1. A Button to allow users to clear the image in the PictureBox
2. A ListBox to allow users to change the colour of the pen. Provide few options for colour.
3. A way (radio or list) to set the drawing width. Provide few options for the width.
4. A button to exit
Be sure that when the user makes a selection from the menu, the appropriate control is updated to reflect the user's choice of colour and width.
Important Note: You will need to use some of the mouse events. In particular the mouse move event should contain your drawing rather than the paint event of the picture box. This has the effect of you minimize the drawing would be gone which is ok for this small assignment.
i'll post what i have write
VB.NET:
Public Class Form1
Dim image1 As Bitmap
Dim gr As Graphics
Dim Pen1 As New Pen(Color.Black, 5)
Private Sub picturebox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
gr = PictureBox1.CreateGraphics 'Paints the graphic to the form
End Sub
Private Sub picturebox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
gr.DrawLine(Pen1, e.X, e.Y, e.X + 3, e.Y + 3)
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
End Sub
Private Sub lstColour_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstColour.SelectedIndexChanged
If Me.lstColour.SelectedIndex = 0 Then
Pen1.Color = Color.Blue
ElseIf lstColour.SelectedIndex = 1 Then
Pen1.Color = Color.Red
ElseIf lstColour.SelectedIndex = 2 Then
Pen1.Color = Color.Green
End If
End Sub
Private Sub lstWidth_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstWidth.SelectedIndexChanged
End Sub
End Class
but whenever i run the form it gives me an error on that part
VB.NET:
gr.DrawLine(Pen1, e.X, e.Y, e.X + 3, e.Y + 3)
and i don't know how to clear the picbox after drowing and how to change the size of drowing..!!
i know i'm asking alot but i want to learn
Thanks in advance