Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Creating an Images Using Mouse in Visual Basic.Net

Author: DevASP
Download Source Code : 497_DrawingWithMouse.zip

In this article I will try to explain you how you can draw any thing in picture box and how to change the pen size to draw images in Visual Basic.Net (VB.Net).

Open Visual studio, Create a new application using vb.net and drag a following controls on the from

Menu item control

Picture Box control

 

Set the following properties of the from

 

Set Form Border Style property to Fixed Tool Window

Auto Scale to False

Minimum size to 712, 536

Size = 712, 536

Start Position to center

 

Set the following properties of the Picture box

 

Back color equals to white

Border Style equals to Fixed3D

Cursor equals to cross

Dock equals to fill

 

Now add the file menu in main menu with new and Exit as a sub menu also add the size menu having “2”, “4”, “6”, “8”, “10”, “20”, “25”, “50”, “75”, “100”, “150”, “200” as a sub menu

 

Before writing the code imports the following namespace

 

Imports System.Drawing

 

Create following global variables

 

Dim k As Integer = 20

Public g As Graphics

Private sb As New System.Drawing.SolidBrush(System.Drawing.Color.Black)

 

Double click on the form and write the following code on from load event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        g = picbox.CreateGraphics()

End Sub

 

Write the following code on the new menu item click event

 

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

        Dim clear As Bitmap

        picbox.Image = clear

End Sub

 

Write the following code on the Exit menu item click event

 

Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click

        Application.Exit()

End Sub

 

Write the following code on the 2 menu item click event

 

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click

        k = 2

End Sub

 

Write the following code on the 4 menu item click event

 

Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click

        k = 4

End Sub

 

Write the following code on the 6 menu item click event

 

Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click

 

        k = 6

 

End Sub

 

Write the following code on the 8 menu item click event

 

Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem8.Click

 

        k = 8

 

End Sub

 

Write the following code on the 10 menu item click event

 

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click

 

        k = 10

 

End Sub

 

Write the following code on the 20 menu item click event

 

Private Sub MenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem10.Click

 

        k = 20

 

End Sub

 

Write the following code on the 25 menu item click event

 

Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem14.Click

 

        k = 25

 

End Sub

 

Write the following code on the 50 menu item click event

 

Private Sub MenuItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem13.Click

 

        k = 50

 

End Sub

 

Write the following code on the 75 menu item click event

 

Private Sub MenuItem15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem15.Click

 

        k = 75

 

End Sub

 

Write the following code on the 100 menu item click event

 

Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem12.Click

 

        k = 100

 

End Sub

 

Write the following code on the 150 menu item click event

 

Private Sub MenuItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem16.Click

 

        k = 150

 

End Sub

 

Write the following code on the 200 menu item click event

 

Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem11.Click

 

        k = 200

 

End Sub

Article Comments
all information and codings are useful

Posted on 3/21/2008 1:30:45 AM by Ramya

Excellent

Posted on 3/21/2008 1:33:09 AM by Punitha

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating a Dynamic Banner in Visual Basic.net

Disclaimer - Privacy
© 2002-2017 DevASP.net