473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I'm having a problem with drawing on picturebox in vb.net programing.

3 New Member
I'm having a problem with drawing on picturebox in vb.net programing.
I draw line(or another shape's) on picturebox, anytime screen refreshes(open dialogbox ro menu,...) the drawn line on picturebox disapears.

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
x1 = e.Location.X
y1 = e.Location.Y
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
x2 = e.Location.X
y2 = e.Location.Y
If toolbox = "line" Then drawline()

Sub drawline()
Dim g As Graphics = PictureBox1.CreateGraphics()
g.DrawLine(Pens.Black, x1, y1, x2, y2)
End Sub
Mar 25 '06 #1
1 13021
RichardH
4 New Member
The onpaint event fires every time a form or control needs to be redrawn to the screen. When this happens, your drawline() sub would need to be called too for the line to be redrawn. Your start and end point variables would have to persist outside of the sub as well.
Apr 3 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kylin | last post by:
uses statement: System.Windows.Forms.PictureBox pictureBox1; System.Windows.Forms.Panel panel1; pictureBox1 = new System.Windows.Forms.PictureBox(); panel1 = new...
6
by: chau_fai | last post by:
I have a window Form called "Form2". There is only one button and a panel returned from a static method of the "Coord" in this form. In the panel returned, there is a button that can choose image...
7
by: news | last post by:
This may be a stupid question, but if I don't ask I'll never know ;) Ok, here it goes.... I am writing an application that renders an image in one picturebox and a graph in another. The image...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
3
by: active | last post by:
I draw text in a bitmap and then draw the bitmap on a picturebox and get text that is not all displayed the same. Note the different text style in the (40, 100) area. Got any insight into...
8
by: Ryan Chavez | last post by:
Hello, I'm working on a project that basically draws lines onto a PictureBox control. Now I'm using a Timer with an interval of 100 to draw the information. Now my code looks something like this:...
5
by: Steve Marshall | last post by:
Hi all, I am converting an app which used a picturebox to draw graphs etc onto, then saved them to a file. I can certainly draw things onto a picturbox in VB.NET, but how do I save them to a...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.