以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]点击打印按钮后如何给数据表指点列赋值 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=172146) |
-- 作者:jygyyl -- 发布时间:2021/9/26 17:07:00 -- [求助]点击打印按钮后如何给数据表指点列赋值 点击打印按钮代码如下:请老师指点,如何给数据表指点列赋值(已打印的行的“打印”列为true或=1) Dim c1,c2 As WinForm.ComboBox Dim t1,t2,t3,t4 As WinForm.TextBox Dim t11,t21,t31,t41 As Integer Dim Ch1 As WinForm.CheckBox Ch1= e.Form.Controls("CheckBox1") c1 = e.Form.Controls("ComboBox1") c2 = e.Form.Controls("ComboBox2") t1 = e.Form.Controls("TextBox1") t2 = e.Form.Controls("TextBox2") t3 = e.Form.Controls("TextBox3") t4 = e.Form.Controls("TextBox4") t11 = t1.Value t21 = t2.Value t31 = t3.Value t41 = t4.Value Dim c11 As BarCodeEnum Select Case c1.Value Case "Codabar" c11= BarCodeEnum.Codabar Case "Code128" c11= BarCodeEnum.Code128 Case "Code39" c11= BarCodeEnum.Code39 Case "Code93" c11= BarCodeEnum.Code93 Case "CodeI2of5" c11= BarCodeEnum.CodeI2of5 Case "Ean13" c11= BarCodeEnum.Ean13 End Select Dim c21 As BarDirectionEnum Select Case c2.Value Case "Normal" c21= BarDirectionEnum.Normal Case "Down" c21= BarDirectionEnum.Down Case "Up" c21= BarDirectionEnum.Up End Select If t11 = 0 OrElse t21= 0 Then \'筛选后全部选定区域 With CurrentTable .Select(0,0, .Rows.Count - 1, .Cols.Count - 1) End With Else With CurrentTable .Select(t11-1, 0,t21-1, .Cols.Count - 1) End With End If Dim doc As New PrintDoc \'定义一个报表 doc.PageSetting.Width = 51 \'纸张宽度为100毫米 doc.PageSetting.Height = 31 \'纸张高度为120毫米 Dim tbl As Table = CurrentTable \'Doc.Columns.Add() \'增加第一栏 \'Doc.Columns.Add() \'增加第二栏 \'第一栏的宽度为60毫米 \'Doc.Columns(0).Spacing = 20 \'栏间距1毫米 For i As Integer = tbl.TopRow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 Dim ra As New prt.RenderArea \'定义一个容器 \'ra.Width = "Parent.Width" ra.width=50 ra.height=30 ra.CanSplitHorz = False \'禁止水平分割 ra.CanSplitVert = False \'禁止容器因为分页而被垂直分割 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 doc.PageSetting.Landscape = True \'横向打印 Doc.PageSetting.PaperKind = 0 Doc.PageSetting.LeftMargin = 2 \'设置左边距 Doc.PageSetting.RightMargin = 2 \'设置右边距 Doc.PageSetting.TopMargin = 2 \'设置上边距 Doc.PageSetting.BottomMargin = 2 \'设置下边距 \'指定行数?列数?列宽?行高 rt.Rows.Count = 3 \'设置总行数 rt.Cols.Count = 3 \'设置总列数 rt.Height = 26 \'设置表格的高度 \' rt.Width = "Parent.Width" \'设置表格的宽度 rt.Cols(0).Width = 30 \'第一列的宽度 rt.Cols(1).Width = 4 \'第二列的宽度 \'rt.Cols(2).Width = 12 rt.Rows(1).Height = 10 \'第二行的高度(用于显示条码) \'设置合并单元格 rt.Cells(1,2).SpanRows = 2 \'第2行第3个单元格向下合并2行(用于显示二维码) rt.Cells(0,0).SpanCols = 2 \'向右合并2列 rt.Cells(1,0).SpanCols = 2 \'向右合并2列 rt.Cells(2,0).SpanCols = 2 \'向右合并2列 \'设置表格样式 rt.CellStyle.Spacing.All = 0.5 \'单元格内容缩进1毫米 rt.Style.Spacing.Bottom = 2 \'和下一个出入证的距离是8毫米 \'rt.Style.GridLines.All = New prt.Linedef \'设置网格线 \'下面很简单,指定每一个单元格的内容 rt.Cells(0,0).Text= rw("机构") \'"部门" rt.Cells(0,2).Text = rw("组别")&rw("编组") \'"姓名" rt.Cells(2,0).Text= rw("条码") \'"编号" Dim rbc As New prt.RenderBarCode() rbc.Width = t31 rbc.Height = t41 rbc.BarCodeType = c11 rbc.BarDirection = c21 rbc.Text = rw("条码") If Ch1.Checked = True Then rbc.ShowText = True \'是否显示编码 Else rbc.ShowText = False End If rt.cells(1,0).RenderObject = rbc ra.Children.Add(rt) \'加入到容器中 Dim img As prt.RenderImage Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.QRCode Bar.BarRatio = 0.3 Bar.BarWidth = 15 Bar.BarHeight = 15 bar.Code = rw("条码") img = new prt.RenderImage img.Image = bar.GetImage img.Width = 15 img.height= 15 \'img.Style.Spacing.All = 0.25 img.X=34 img.Y=8 \'rt.cells(2,2).RenderObject = img ra.Children.Add(img) Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next Doc.PrinterName = "ZDesigner GK888t" Doc.print \'Doc.Preview() [此贴子已经被作者于2021/9/26 17:18:22编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/9/26 17:18:00 -- For i As Integer = tbl.TopRow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) rw("打印") = true
|