TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shay Wilner
NA
3
0
Drawing a line into a picture box
Apr 21 2010 6:04 PM
Hello every body
I 'm new in vb.net I tried to write a little app drawing a line into a picture box and
show it
here the code
Public
Class
Form1
Private
Sub
draws()
Dim
mypen
As
Pen
Dim
gr
As
System.Drawing.Graphics
gr = panel2.CreateGraphics
mypen =
New
Pen(Color.Chocolate, 3)
gr.DrawLine(mypen, 20, 20, 700, 700)
End
Sub
Private
Sub
Form1_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
DisplayPanel()
End
Sub
Private
Sub
Form1_Paint(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.Forms.PaintEventArgs)
Handles
Me
.Paint
draws()
End
Sub
Private
Sub
DisplayPanel()
Me
.Panel2.BackgroundImage = Image.FromFile(
"E:\drawnet\Draw\Draw\bin\Debug\lcws\board.bmp"
)
Me
.Panel2.Width =
Me
.Panel2.BackgroundImage.Width
Me
.Panel2.Height =
Me
.Panel2.BackgroundImage.Height
Me
.Panel2.Left =
Me
.Width / 2 -
Me
.Panel2.Width / 2
Me
.Panel2.Top =
Me
.Height / 2 -
Me
.Panel2.Height / 2
End
Sub
End
Class
panel2 is the name of the picture box.
When i run the app i didn't see the line
but only if i create an event like mouse click etc. why?
thanks for explanation
Reply
Answers (
2
)
Actual CompTIA SY0-201 Exam Sheets, You Pass Guaranteed!
im