Drawing Line On Picturebox?

May 27, 2010

My program is giving the error: "End of statement expected" The red lines are the ones giving errors. I'm trying to draw lines on a picturebox to create a graph

Dim iScale As Single
Const Distance = 1000
pictureBoxGraph.ForeColor = QBColor(0)

[Code]....

View 16 Replies


ADVERTISEMENT

Drawing On Picturebox Vs Drawing On Form?

Feb 18, 2012

I need some code to draw a resizable, draggable rectangular cursor (or selection box) on a picturebox. I found some excellent code (albeit rather old) that does just that, but on a form rather than a picturebox. I have tried converting the code - basically moving things to the picturebox events (Paint, MouseDown, MouseMove etc). It nearly works but leaves a trail behind it when you move or resize the cursor. In other words, the selection rectangle is not being erased before being drawn in the new position.

Is there some fundamental difference between drawing graphics on a form and drawing on a picturebox that would cause this behaviour? Something like, when you invalidate a form and cause a redraw it erases what you did last? If not, then I just need to dig a bit further and work out how the cursor is being erased from the previous position.

Here's the original code that works fine on a form:

Private DragRect As New RectangleF(20, 20, 100, 80)
Private Adornments(7) As RectangleF
Private MouseInRect As Boolean = False

[Code]....

View 1 Replies

Part Of The Line Goes Below 0 It Starts Drawing The Line Inverted Again?

Dec 3, 2010

This is more of a mathematical problem than programming problem.I have created a very basic 3D engine using Visual Basic .Net. It displays lines on the screen with an additional z axis. The engine works, however when part of the line goes below 0 it messes up and starts drawing the line inverted again.

This is how it calculates the points:

y = (point.y / z) + offset.y + camera.y
x = (point.x / z) + offset.x + camera.x

Can anyone work out a way to only draw part of the line when it intersects the z=0 axis?

View 1 Replies

Draw Line On PictureBox In .NET When Pass PictureBox As Parameter To Some Function

Jul 17, 2010

In VB6 I used some pattern of programming..I passed the picturebox as parameter to some procedure in some class and inside this procedure paint all needed graphics using this class methods.Now I want upgrade my application to vb.netBut all samples for line drawing show me how to draw inside paint event.[code]

View 2 Replies

Drawing A Lines In A Picturebox?

Jan 18, 2011

I've looked and tried.. and for some reason just don't seem to be getting right now.

I have a picturebox that is 250x500, I want to draw a vertical line from the top to the bottom.

Using gs = pbMap.CreateGraphics
'Do While x.X < 250
'gs.DrawLine(Pens.Red, x, y)

[Code].....

View 7 Replies

Drawing On A Picturebox Control?

Jul 28, 2009

This form has a picturebox and a button. The program draws a random line onto the picturebox every time the button is pressed. I want to modify the program so that it also draws a line onto the picturebox when the program is first run. I added a draw() to the form_load event but that didn't work. What do I need to do?

Public Class Form1
Dim x1 As Integer
Dim y1 As Integer

[code]....

View 1 Replies

How To Save Drawing In Picturebox

Sep 25, 2011

I have here a code to draw on a picturebox and when I am trying to save the drawing, it seems that it cant detect whats inside the picturebox.

Here is my
Public Class Signature
Inherits System.Windows.Forms.Form
Dim mousePath As New System.Drawing.Drawing2D.GraphicsPath()
Dim myAlpha As Integer = 100 ' declare a Alpha variable
Dim myUserColor As New Color()
Friend WithEvents btnSave As System.Windows.Forms.Button
[Code] .....

View 11 Replies

Drawing A Resizable Rectangle On Picturebox

May 26, 2010

I have try many different methods but still no avail.how to do this? As i found a good tutorial over

here where it create a resizable rectangle on a form. But what i want is on a picturebox with image.

View 7 Replies

Drawing Multiple Images In Picturebox?

Oct 7, 2009

I got down the drawimage part. The problem I am having, is when I draw another image, it replaces the old one. Here is my

vb
Public Class Form1
Dim PicPoint As Point

[Cod].....

View 27 Replies

Save The Drawing That Is In A Picturebox To File ?

Feb 22, 2009

How can I save the drawing that is in a picturebox to file?

Here is my code so far:

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then

[CODE]..........................

View 2 Replies

VS 2010 - Clearing The Drawing In PictureBox

Mar 13, 2012

I've problem with clearing the drawing in PictureBox. The parts of a drawing are created with PictureBox1_ Paint Event like this: Name is one of the Subs (just part of a drawing). I've created a second event Timer1_Tick in which I want to clear the drawing created before but I can't reach it just with g.Clear(Color.White).

View 8 Replies

VS 2010 Drawing Image To Picturebox?

Jul 20, 2011

I have 4 control 3 button and 1 picturebox

vb.net
Private sub Button1 Dim bm As Bitmap = New Bitmap("D:Trening4 - Copy.bmp"

[code].....

View 4 Replies

VS 2010 Save Drawing From PictureBox?

Jun 4, 2011

I'm trying to save the lines I drew in a PictureBox as a bitmap, but it just returns blank images...This is the code I have now:

vb
'Draw a grid on PictureBox named draw
For x As Integer = 0 To bWidth

[code]....

View 3 Replies

VS 2008 - Draw A Line On Top Of A Picturebox But It Keeps Going Behind The Picturebox?

Jan 4, 2011

I am trying to draw a line on top of a picturebox but it keeps going behind the picturebox, even when I do Line.BringToFront()

View 10 Replies

Basics: Drawing Graph With Picturebox - Image

Jan 9, 2011

I am new to vb.net, from VB6. Trying to understand drawing a simple line graph into a picturebox, which was so simple in VB6 ! From code snippets, I can see the basic idea using an bitimage to draw the lines and then showing it in a picturebox. I don't understand how to (simulate) scaling of the bitmap's x/y scales like you could do with VB6's .Scale.

View 1 Replies

Drawing Graphics - How To Clear Image In PictureBox

Nov 23, 2011

I have 1 image in picturebox. Now I draw some rectangles. I'm trying clear the image (only rectangles and left the image) without success.

Private Sub btnImageSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImageSelection.Click
Dim intImages As Integer = 0
Dim intImagesLine As Integer = 0
Dim intImagesColune As Integer = 0
picImage.Image = PictureBox1.Image
[Code] .....

The cycles for is for show the rectangules and works fine. but
i.Clear(Color.Blue)
The image is clear but the rectangles are showed and then unshowed.

View 19 Replies

VS 2008 - Drawing Graph On PictureBox Using Coordinates

Sep 21, 2009

VB 6 has a ScaleHeight and ScaleWidth property which VB 2008 does not support and this is causing me fits to work around. I'm trying to draw some lines (a graph) on a Picture Box (or a Panel) using my own coordinates (not pixels). This can't be all that hard can it?

View 3 Replies

VS 2008 : Drawing With Multiple Colors In A PictureBox?

Apr 13, 2011

I'm basically trying to make a simple, easy-to-use, paint program. I seem to be having problems with using multiple colors in the PictureBox1_Paint option. It draws the graphics but when you change the brush color and click in the picturebox it changes the colors of the previous graphics to the color you are currently trying to use. I need it to allow multiple colors.

Here's the code that I'm currently using..

Imports System.Drawing.Drawing2D
Public Class DynosPaint
Inherits System.Windows.Forms.Form
Private IsFormBeingDragged As Boolean = False

[code]....

View 3 Replies

VS 2008 Drawing With Multiple Colors In A PictureBox?

Apr 13, 2011

I'm basically trying to make a simple, easy-to-use, paint program. I seem to be having problems with using multiple colors in the PictureBox1_Paint option. It draws the graphics but when you change the brush color and click in the picturebox it changes the colors of the previous graphics to the color you are currently trying to use. I need it to allow multiple colors.

Here's the code that I'm currently using..

Imports System.Drawing.Drawing2D
Public Class DynosPaint
Inherits System.Windows.Forms.Form

[code]....

View 1 Replies

VS 2010 Drawing A Curve/graph In Picturebox?

Nov 21, 2009

My problem is centering the 0,0 points of my graph to the center of my picturebox

Dim picBoxWidth As Integer = picGraf.Size.Width
Dim picBoxHeight As Integer = picGraf.Size.Height
Dim halfWidth As Integer = picGraf.Size.Width / 2

[code]....

So how to I tell it to start at the center of my picturebox names (picgraf) btw.

View 1 Replies

Drawing A String On A Picturebox In The Form Load Event?

Jun 13, 2010

I have a question about drawing a string on a picturebox in the form load event. So I have a picturebox on a form and in the form load event of this form I have this code:

Dim gx As Graphics = PictureX.CreateGraphics
Dim f As Font = New Font("Arial", 8)
Dim brr As Brush = New SolidBrush(Color.Black)
' Add the copyright text
gx.DrawString("1", f, brr, 2, 5)

But when I load the program nothing is drawn in the picturebox. Is there something wrong with the code or should I use the paint event of the picturebox?

By the way I also used this code in another program and there it works flawlessly, everything is drawn in the right place there when i load the program.

View 14 Replies

Interface And Graphics :: VB2010: Picturebox Drawing Disappears?

May 26, 2012

Problem1: I have a picturebox on a form. I have also managed to draw several PNG files with transparency onto the picturebox (see below). However, If I move the form outside the border and move it back, the image is gone. My source so far:

Dim k1 As New Bitmap(My.Resources.image1)
Dim k2 As New Bitmap(My.Resources.image2)
Dim drawMe As Graphics = PictureBox1.CreateGraphics
Dim bgcolor As Color = Color.FromArgb(128, 128, 128)
drawMe.Clear(bgcolor)

[Code]...

View 10 Replies

VS 2008 Drawing Chart In Picturebox Then Creating Bmp And Saving

Aug 3, 2009

I'm drawing a chart in a pictruebox with a sub called Techart. After that I'm trying to turn the drawing into a bitmap, so that it will be persistant and also so that I'll be able to save it. This is what I've got from searching the forum:

[Code]...

View 5 Replies

Drawing A Line At An Angle?

Jan 22, 2011

if i use

Dim Gr As Graphics = SomePanel.CreateGraphics()
Gr.Drawline(StartingPoint, EndingPoint)

I want to be able to have a line drawn from point a to b, but be able to rate it 90 degress based on user input so if the user inputs 70 I want it to rotate 30 degree's to simulate a 70 deg relationship to a horizontal line that it touches if that makes any sense. a is starting point b is the user inputs 70 and it draws it at 70 in relationship to the horizontal lineheres the image that i forgot to post above Attached image(s)

View 1 Replies

Drawing A Line In VB With OpenGL

Nov 6, 2010

I was wondering if anyone could steer me to any good references to using OpenGL in vb.Net? I wanted to try a simple line drawing test to start off with, and came across many old discussions about using CsGl or the Tao Framework. But I could not get CsGL to import into Net2008 (the Add Reference window simply could not see the DLL that was clearly there when using Windows Explorer). And although I could get Tao to import OK, and found portions of one person's project, I figured that somehow the GL window he was referring to had to first be set up as a GL object (new class?).In addition, all the OpenGL books I have looked at only discuss OGL with respect to some version of C.From what I have gathered, you need a connector between vb.Net and the opengl32.dll libraries and that is what CsGL and Tao are about. But the edumucation resources seem very few.

View 13 Replies

Drawing A Line On Form

Feb 24, 2012

how to draw in vb.net, and I figured the easiest way is to get my hands dirty and start coding. I figure that the best way to start is by drawing a line on the form. What I'm trying to do is use the graphics.drawline(), but I'm failing. This is what I'm using so far

[Code]...

View 2 Replies

Drawing A Line With Points?

May 13, 2009

I have a question about drawing lines. Most of the code snippets I've seen approach drawing a line with the mouse down as the startpoint and the mouse up as the endpoint. But I am trying to draw a line by startpoint as
a mouse click and then an endpoint as a mouse click just as you do on a typical cad program.

View 8 Replies

Drawing A Multicolored Line?

May 30, 2011

That's vertical and 1 pixel wide. This is for a mulitiprocessor performance monitor.How do I do it....if you tell me which routine to use... I'll take it from there. I don't think the routine is

System.Drawing.Graphics.DrawLine, because it's looks to an external reference like I'm putting random pixels in.If possible I need to put the pixels in by hand. Besides this line of pixeld is another line of pixels for another epoch. They are not related numrically.

View 1 Replies

VS 2005 Drawing On PictureBox Erase When A Window Move On Front

Dec 25, 2009

I used a picturebox to allow user draw lines by mouse. I used this code in mouse down:


Dim D As New System.Drawing.Pen(DrawingColor, 2)
Dim g As Graphics = PB.CreateGraphics()
g.DrawLine(D, X1, Y1, X2, Y2)

but when a window appear on front of picturebox... its seams that picturebox redraw itself, so drawn lines erased.

View 5 Replies

Dynamic Opacity Line Drawing?

Dec 12, 2011

I am doing a project with graph (VB.NET). I am drawing a line handling dynamic property ( opacity changes based on DB value). I don't know how to change the opacity.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved