By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Drawing help

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.