我的打印预览代码不起作用。我如何使这项工作。帮助将不胜感激。谢谢你。我试图显示我的最终结帐收据,我无法粘贴图片,所以它是这样的:
客户 ID: 职务: 姓名: Bob 地址: 汽车: 汽车 ID: 升级: 成本: 产品 ID: 商店 ID:
我希望这些在打印预览屏幕的列布局中。我该怎么做?
我还收到一条警告:以前使用过变量“LineToPrints”,它可能导致空值。
Dim TitleFont As New Font("Courier New", 15, FontStyle.Bold)
Dim MyFont As New Font("Courier New", 12, FontStyle.Regular)
Dim MyFormat As String = "{0, 15}{1,15}"
Dim LineToPrints As String
Dim X As Integer
Dim Y As Integer
X = 15
FontHeight = MyFont.GetHeight(e.Graphics)
e.Graphics.DrawString("Checkout Receipt", TitleFont, Brushes.Black, X, Y)
For Y = 15 To 165 Step 15
Select Case Y
Case 30
LineToPrints = String.Format(MyFormat, "Customer ID: " & OneCustomer.CustomerID)
Case 45
LineToPrints = String.Format(MyFormat, "Title: " & OneCustomer.Title)
Case 60
LineToPrints = String.Format(MyFormat, "Name: " & Trim(OneCustomer.FirstName) & Trim(OneCustomer.LastName))
Case 75
LineToPrints = String.Format(MyFormat, "Address: " & OneCustomer.Address)
Case 90
LineToPrints = String.Format(MyFormat, "Car(s): " & OneBooking.Car)
Case 105
LineToPrints = String.Format(MyFormat, "Car ID: " & OneBooking.CarID)
Case 120
LineToPrints = String.Format(MyFormat, "Upgrades: " & OneBooking.Upgrade)
Case 135
LineToPrints = String.Format(MyFormat, "Cost: " & FormatCurrency(TotalCost))
Case 150
LineToPrints = String.Format(MyFormat, "Product ID: " & OneStock.ProductID)
Case 165
LineToPrints = String.Format(MyFormat, "ShopID: " & OneStock.ShopID)
End Select
e.Graphics.DrawString(LineToPrints, TitleFont, Brushes.Black, X, Y + 10)
e.Graphics.DrawString("Thank You For Purchasing At 'Ford Mustaang Selection Buyout'.", TitleFont, Brushes.Black, X, Y)
Next