How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox?
How to draw string or line in Picturebox? How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
Go Back  Xtreme Visual Basic Talk > > > How to draw string or line in Picturebox?


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2006, 05:09 AM
HolySanta HolySanta is offline
Newcomer
 
Join Date: Apr 2006
Posts: 8
Exclamation How to draw string or line in Picturebox?


Hi guys, I know this is a noob question coz I can't find any threat that can help me in this.

I had a picture box that I want to draw a ruler on it. I try something like the code below but it just can't works. The picturebox did not show any thing.

'This is to draw the line
picRuler.CreateGraphics.DrawLine(Pens.Black, 0, 0, 0, 5)
'This is to draw the string
picRuler.CreateGraphics.DrawString("Inches", myFont, 0, 0)

Maybe I left something out coz I when I tried to use form's creategraphics object, nothing come out in the font as well.

Please help.
Reply With Quote
  #2  
Old 06-22-2006, 10:25 AM
JNewt's Avatar
JNewt JNewt is offline
Centurion
 
Join Date: Apr 2003
Location: KY (Home), ID (College)
Posts: 138
Default

You need to redraw every time the picturebox repaints. The best way to do this is place your drawing code in the Paint event of the picturebox and use the graphics object that is passed to you (e.Graphics).
__________________
Erat autem fuenum multum in loco. -John 6:10
Please forgive my English -I'm a modern American.
Reply With Quote
  #3  
Old 06-22-2006, 12:00 PM
HolySanta HolySanta is offline
Newcomer
 
Join Date: Apr 2006
Posts: 8
Default

Quote:
Originally Posted by JNewt
You need to redraw every time the picturebox repaints. The best way to do this is place your drawing code in the Paint event of the picturebox and use the graphics object that is passed to you (e.Graphics).
Thanks JNewt. Everything going smoothly. But one question, if I have a run-time drawing, like when user click a button and the picturebox will draw something, we need to redraw right? but how do we call the redraw event?
Reply With Quote
  #4  
Old 06-22-2006, 12:23 PM
JNewt's Avatar
JNewt JNewt is offline
Centurion
 
Join Date: Apr 2003
Location: KY (Home), ID (College)
Posts: 138
Default

To tell a control to repaint you simply need to use the Invalidate method of the control (in this case the picturebox).
__________________
Erat autem fuenum multum in loco. -John 6:10
Please forgive my English -I'm a modern American.
Reply With Quote
  #5  
Old 06-22-2006, 01:09 PM
HolySanta HolySanta is offline
Newcomer
 
Join Date: Apr 2006
Posts: 8
Default

Thanks a lot JNewt. It really helps.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox? How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox? How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
 
How to draw string or line in Picturebox?
How to draw string or line in Picturebox?
 
-->