Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / November 2006

Tip: Looking for answers? Try searching our database.

Help with drawing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Long - 07 Nov 2006 15:36 GMT
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.

Dim g as Graphics = Picture1.CreateGraphics

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
Bryan Phillips - 07 Nov 2006 17:46 GMT
Where are you running the code?  In the paint event of the PictureBox?

Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com

> Hello,
> there is probably something obvious here that I'm just not seeing but I am
[quoted text clipped - 35 lines]
> Thanks
> Steve
Steve Long - 07 Nov 2006 17:59 GMT
In the Refresh event of the UserControl.

Steve

> Where are you running the code?  In the paint event of the PictureBox?
>
[quoted text clipped - 44 lines]
>> Thanks
>> Steve
Bob Powell [MVP] - 09 Nov 2006 07:00 GMT
See the GDI+ FAQ #1 most asked question.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> In the Refresh event of the UserControl.
>
[quoted text clipped - 49 lines]
>>> Thanks
>>> Steve

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.