Windows Develop Bookmark and Share   
 index > Windows Forms General > Print document with Alignment
 

Print document with Alignment

Hello.

I have been trying to print a document from my application, I have been able to fix a couple of problems my self but now Im stuck.

I would like to habe the possibility to align text(left,center,right), it must be possible the set alignment of each column separatly.

How could I integrade in my code bellow ?



The code is based on an example called vbreport found at Microsofts homepage.


Here I write some data from a from my datareadr, then I set the alignment, the 0 indicates the fontstyle(0 for nomal,1 for bold etc.)
e.Write(reader("KontoNr"), ReportLineJustification.Left, 0)


Here is the sub which sets the location of the text
Public Sub Write(ByVal Text As String, _
        ByVal Justification As ReportLineJustification, ByVal Style As Integer)

        Select Case Justification
            Case ReportLineJustification.Left
                mX = 5
    End Select

End Sub


Here I actualy draw the text to the "paper", here I would like to have possiblity to change the alignment.

Public Sub Write(ByVal Text As String, ByVal Font As String, ByVal Size As Integer, ByVal Style As Integer)
        ' Fontstyle is set by its number as an integer
        'Example
        'FontStyle.Regular = 0

 Dim the_font As New Font(Font, _
                Size, Style, GraphicsUnit.Point)

        Graphics.DrawString(Text, the_font, mBrush, mX, mY)
        mX += CInt(Graphics.MeasureString(Text, the_font).Width)

End Sub
le_montmartre  Monday, November 14, 2005 7:43 PM
I would really apriciate some help on this one
le_montmartre  Tuesday, November 15, 2005 2:21 PM

Perhaps you could try using a StringFormat object and including that in the DrawString parameters.

 StringFormat strFmt = new StringFormat();

strFmt.Alignment = StringAlignment.Center;

Is that what you're after?

Toop

Toop  Monday, January 16, 2006 5:45 PM

You can use google to search for other answers

Custom Search

More Threads

• Child Form Icon not Always Showing
• Deleting projects from visual studio's start page
• The property 'ClientID' on type 'System.Web.UI.Control' cannot be serialized
• Want to change the font and color of context menu and confirmation dialog box
• Displaying Pictures
• Single Key Shortcut for Menuitems
• Implementing editor for all props
• c# to Vb.net
• Exception Handling in Windows Forms
• Develop .net application for windows nt 4.0