窗口打印,自动选择,代码如下:
Dim sp As WinForm.SplitPanel = e.Form.Controls("SplitContainer1").Panel1
Dim doc As PrintDoc = e.Form.GernatePrintDoc(sp)
Dim t As Table = Tables("收费明细")
For i As Integer = 0 To t.Rows.Count -1
If t.Rows(i)("打印状态") = 0 Then
t.Position = i
doc.Preview()
Tables("收费明细").Current("打印状态") = True
Exit For
End If
Next
出现的问题是:如果当前行是第3行,会先打第3行,同时返回第1行。打印顺序是3-1-2;不是1-2-3。
我的愿望是按打印按钮后,不管当前行是哪一行,首先返回"打印状态" = 0的第一行,然后逐行往下打。打完后点击按钮是不会继续打印的。
测试后发现执行顺序是:doc.Preview()-- t.Position = i-- Tables("收费明细").Current("打印状态") = True
和代码编写的顺序不符。
没办法,另加了个条件判断,达到了预想效果,最后修改代码如下:
Dim t As Table = Tables("SFMX")
For i As Integer = 0 To t.Rows.Count -1
If t.Rows(i)("DY") = 0 Then
t.Position = i
Exit For
End If
Next
Dim sp As WinForm.SplitPanel = e.Form.Controls("SplitContainer1").Panel1
Dim doc As PrintDoc = e.Form.GernatePrintDoc(sp)
Dim Count As Integer = DataTables("SFMX").Compute("Count(DY)","DY = 0")
If Count > 0 Then
doc.Preview()
Tables("SFMX").Current("DY") = True
End If
[此贴子已经被作者于2013-3-12 0:45:50编辑过]