2009-08-07 62 views
2

請幫幫我。我想從.NET應用打印一些報告。 我讀了如何使用PrintDocument類和Graphics對象來繪製我的報告。 但我不`噸知道哪些單元在方法中使用,例如:打印.net座標單位

Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs) 
    MyBase.OnPrintPage(e) 

    Dim g As Graphics = e.Graphics 
    g.PageUnit = GraphicsUnit.Millimeter 
    Dim p As New Pen(Brushes.Red, 5) 
    g.DrawRectangle(p, 5, 5, g.VisibleClipBounds.Width - 10, g.VisibleClipBounds.Height - 10) 

End Sub 

在方法:

Public Sub DrawRectangle(ByVal pen As System.Drawing.Pen, ByVal x As Single, ByVal y As Single, ByVal width As Single, ByVal height As Single) 

參數X,Y,寬度,高度都在像素,毫米英寸或什麼?

我試着在谷歌上找到答案,但什麼都沒有建立。 我完全困惑。

感謝

+0

我改變了代碼,但g.VisibleClipBounds.Width returnts 799.333,和它了太多的親A4頁面如果以毫米爲單位 – Cicik 2009-08-07 14:13:16

+0

Cicik,如果您對代碼進行更改,請將其標記爲這樣。 GraphicsUnit.Millimeter有幫助嗎? – 2009-08-07 14:19:10

+0

好的將來我會標記變化,沒有毫米毫米沒有幫助。 矩形永遠不會出現。 – Cicik 2009-08-07 14:24:47

回答