On a Windows
Form, add a PictureBox control named PictureBox1 and write the code below on the
MouseDown, MouseUp, and MouseMove events of the PictureBox.
Press left mouse button and move the mouse in the form as you see a line will be
drawn until mouse is up, wherever you move the mouse.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Form1
Public eventString As String
Public pw As Integer
'Public j As Integer
'Public p As Integer
'Public q As Integer
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs)
Handles PictureBox1.MouseDown
' i = e.X
' j = e.Y
' p = e.X
'q = e.Y
pw = 4 ' you can use numeric updown for selecting pen-width
Select Case e.Button
Case MouseButtons.Left
eventString = "L"
Case MouseButtons.Right
eventString = "R"
Case MouseButtons.Middle
eventString = "M"
Case MouseButtons.XButton1
eventString = "X1"
Join the conversation! Your thoughts help the community grow.