Solved

Strange drawstring problem with numbers

Posted on 2009-07-11
8
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 

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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

717 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