Results 1 to 5 of 5

Thread: How to print a text aligned to right? (RESOLVED)

  1. #1

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200

    How to print a text aligned to right? (RESOLVED)

    The easiest way I found to align a text to right (VB6):

    VB Code:
    1. Private Sub Command1_Click()
    2.     With Printer
    3.         .CurrentX = 1000 - .TextWidth("1,000.00")
    4.         .CurrentY = 2000
    5.         Printer.Print "1,000.00"
    6.         .CurrentX = 1000 - .TextWidth("10,000.00")
    7.         .CurrentY = 3000
    8.         Printer.Print "10,000.00"
    9.         .EndDoc
    10.     End With
    11. End Sub
    What about VB .NET?


    Thanks.
    Last edited by AlvaroF1; Jul 2nd, 2003 at 10:44 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  3. #3

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    Thanks, but it's not clear to me.

    Do you have any example?


    Thank you.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Just one link from MS website http://msdn.microsoft.com/library/de...ClassTopic.asp . There are much more if you just google it .

  5. #5

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    VB Code:
    1. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    2.         Dim fnt As New Font("Arial", 12)
    3.         Dim txt As String
    4.         txt = "1,000.00"
    5.         e.Graphics.DrawString(txt, fnt, Brushes.Black, 1000 - e.Graphics.MeasureString(txt, fnt).Width, 2000, New StringFormat())
    6.         txt = "10,000.00"
    7.         e.Graphics.DrawString(txt, fnt, Brushes.Black, 1000 - e.Graphics.MeasureString(txt, fnt).Width, 3000, New StringFormat())
    8.     End Sub
    9.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    10.         PrintDocument1.Print()
    11.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width