473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Drawing help

Hello,
there is probably something obvious here that I'm just not seeing but I am
trying to draw an alternating colored line on a picturebox and I, for the
life of me, cannot get the line to show up. I'm using VS 2003.
The size of the picturebox is 320 x 24. I using the following code.

For t = 1 To NumTics ' NumTics = 10
If curColor.Equals(mBarColor2) Then
curColor = mBarColor1 ' Black
Else
curColor = mBarColor2 ' Red
End If
XMin = Offset + ((t - 1) * 39)
XMax = Offset + (t * 39)
YMin = Ycen - (Ycen * 0.05) 'Ycen = 12
YMax = Ycen + (Ycen * 0.05)
rect = New Rectangle(XMin, YMin, XMax - XMin, YMax - YMin)
DrawLine(g, curColor, Drawing2D.DashStyle.Solid, rect)
Next t

Public Shared Sub DrawLine(ByRef g As Graphics, _
ByVal lineColor As Color, _
ByVal lineStyle As DashStyle, _
ByVal rect As Rectangle)
Dim pn As New Pen(lineColor, rect.Height)
pn.DashStyle = lineStyle
g.DrawLine(pn, rect.Left, rect.Top, rect.Left + rect.Width, rect.Top +
rect.Height)
pn.Dispose()
End Sub

Any help is greatly appreciate as I am just not seeing what the heck I'm
doing wrong.
P.S. The picturebox is on a userControl

Thanks
Steve
Nov 6 '06 #1
2 993
JR
I can't find your declaration of G for the line DrawLine(g, curColor,
Drawing2D.DashStyle.Solid, rect)
it shoud be something like
Dim g As Graphics = Me.CreateGraphics

"Steve Long" <St**********@NoSpam.comschreef in bericht
news:Oy**************@TK2MSFTNGP02.phx.gbl...
Hello,
there is probably something obvious here that I'm just not seeing but I am
trying to draw an alternating colored line on a picturebox and I, for the
life of me, cannot get the line to show up. I'm using VS 2003.
The size of the picturebox is 320 x 24. I using the following code.

For t = 1 To NumTics ' NumTics = 10
If curColor.Equals(mBarColor2) Then
curColor = mBarColor1 ' Black
Else
curColor = mBarColor2 ' Red
End If
XMin = Offset + ((t - 1) * 39)
XMax = Offset + (t * 39)
YMin = Ycen - (Ycen * 0.05) 'Ycen = 12
YMax = Ycen + (Ycen * 0.05)
rect = New Rectangle(XMin, YMin, XMax - XMin, YMax - YMin)
DrawLine(g, curColor, Drawing2D.DashStyle.Solid, rect)
Next t

Public Shared Sub DrawLine(ByRef g As Graphics, _
ByVal lineColor As Color, _
ByVal lineStyle As DashStyle, _
ByVal rect As Rectangle)
Dim pn As New Pen(lineColor, rect.Height)
pn.DashStyle = lineStyle
g.DrawLine(pn, rect.Left, rect.Top, rect.Left + rect.Width, rect.Top +
rect.Height)
pn.Dispose()
End Sub

Any help is greatly appreciate as I am just not seeing what the heck I'm
doing wrong.
P.S. The picturebox is on a userControl

Thanks
Steve

Nov 7 '06 #2
Hi JR.
It's actually created from the picturebox control Picture1.
Dim g as Graphics = Picture1.CreateGraphics. Shouldn't that do it?

Steve

"JR" <x.*@x.xwrote in message
news:_5**********************@phobos.telenet-ops.be...
>I can't find your declaration of G for the line DrawLine(g, curColor,
Drawing2D.DashStyle.Solid, rect)
it shoud be something like
Dim g As Graphics = Me.CreateGraphics

"Steve Long" <St**********@NoSpam.comschreef in bericht
news:Oy**************@TK2MSFTNGP02.phx.gbl...
>Hello,
there is probably something obvious here that I'm just not seeing but I
am trying to draw an alternating colored line on a picturebox and I, for
the life of me, cannot get the line to show up. I'm using VS 2003.
The size of the picturebox is 320 x 24. I using the following code.

For t = 1 To NumTics ' NumTics = 10
If curColor.Equals(mBarColor2) Then
curColor = mBarColor1 ' Black
Else
curColor = mBarColor2 ' Red
End If
XMin = Offset + ((t - 1) * 39)
XMax = Offset + (t * 39)
YMin = Ycen - (Ycen * 0.05) 'Ycen = 12
YMax = Ycen + (Ycen * 0.05)
rect = New Rectangle(XMin, YMin, XMax - XMin, YMax - YMin)
DrawLine(g, curColor, Drawing2D.DashStyle.Solid, rect)
Next t

Public Shared Sub DrawLine(ByRef g As Graphics, _
ByVal lineColor As Color, _
ByVal lineStyle As DashStyle,
_
ByVal rect As Rectangle)
Dim pn As New Pen(lineColor, rect.Height)
pn.DashStyle = lineStyle
g.DrawLine(pn, rect.Left, rect.Top, rect.Left + rect.Width, rect.Top +
rect.Height)
pn.Dispose()
End Sub

Any help is greatly appreciate as I am just not seeing what the heck I'm
doing wrong.
P.S. The picturebox is on a userControl

Thanks
Steve


Nov 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve Long | last post by:
Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line. I have two methods, one works and one doesn't (it cause...
2
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
1
by: Niels Jensen | last post by:
Hi guys, I have the following code which is supposed to draw a grid in a panel consisting of a specified number of squares. I can get it to draw the grid and activate the autoscroll feature,...
3
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a specific color. I have so far discovered that...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
11
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
2
by: luckyguy4ru | last post by:
Hello every body, I just joined today this forum hopping that i will get really good help here, My final project is to refashioned an artist work which is mostly pencil work, i have fake color...
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...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.