Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Strange drawstring problem with numbers

Posted on 2009-07-11
8
Medium Priority
?
349 Views
Last Modified: 2012-05-07
I have noticed that when I use drawstring to only print numbers, it just prints nothing. However if I put a letter in the string, it prints.

So, "12345" will not work, however
"a12345" will work.

Any help will be much appreciated!
Dim g As Graphics = e.Graphics
 
g.PageUnit = GraphicsUnit.Millimeter
 
g.DrawString("12345", myFont, getBrush(strColor), X, Y)

Open in new window

0
Comment
Question by:syinner
  • 4
  • 3
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24830194
comment out this line and it will work:
'g.PageUnit = GraphicsUnit.Millimeter
0
 

Author Comment

by:syinner
ID: 24830227
unfortunately that didn't work, and if it did, that would be crazy setting to remove!

how does changing the page unit allow me to print numbers?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24830246
can you try this code as is:

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim myFont As Font = Me.Font
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim g As Graphics = e.Graphics

        g.PageUnit = GraphicsUnit.Display

        g.DrawString("12345", myFont, Brushes.Black, x, y)

    End Sub

If it is working like it is working for me, you may have a problem with your Font, your Brush, or your location.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:syinner
ID: 24830278
I tried changing to display but the same problem.

I don't believe its a problem with the location, brush etc because I add a letter into the string and it works with the same settings.

I still don't see how changing the display unit will stop numbers from being printed? when I can print letters, special characters and line breaks.

i have used the same unit to print lines and boxes.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24830292
I can't help you more, it is working on my side.
0
 

Author Comment

by:syinner
ID: 24830305
If I wanted to change the PageUnit permanently, it would be a big problem as its used allot.  

Anyone have any ideas why I am facing this strange problem with drawstring and numbers bearing in mind that it works fine for letters?
0
 
LVL 1

Expert Comment

by:nailgg
ID: 24830497
Hi syinner;

Dim g As Graphics = e.Graphics
Dim MyString as String
 
g.PageUnit = GraphicsUnit.Millimeter
MyString = "12345"
 
g.DrawString(MyString, myFont, getBrush(strColor), X, Y)

Open in new window

0
 

Accepted Solution

by:
syinner earned 0 total points
ID: 24830519
Found the problem...I am using PaperlessPrinter to do my testing as this is in a vmware image... it was just not printing the line

Linked up my actual printer and it printed it!!!

Any suggestions on replacing this driver...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question