Foxtable(狐表)用户栏目专家坐堂 → 字体颜色设置问题


  共有4575人关注过本帖树形打印复制链接

主题:字体颜色设置问题

美女呀,离线,留言给我吧!
采菊东篱下
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
字体颜色设置问题  发帖心情 Post By:2021/12/11 21:57:00 [显示全部帖子]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:排版有误.foxdb
我添加了颜色选择器,结果报错

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20211211215633.png
图片点击可在新窗口打开查看

Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
If e.Form.Controls("TextBox4").Value Is Nothing OrElse e.Form.Controls("TextBox5").Value Is Nothing Then
    messagebox.show("模板长宽不能为空")
    Return
End If
If e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(0) Then
    doc.PageSetting.Width = 297 'A3纸张宽度,单位为毫米
    doc.PageSetting.Height = 420  'A3纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(1) Then
    doc.PageSetting.Width = 210 'A4纸张宽度,单位为毫米
    doc.PageSetting.Height = 297  'A4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(2) Then
    doc.PageSetting.Width = 148.5 'A5纸张宽度,单位为毫米
    doc.PageSetting.Height = 210  'A5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(3) Then
    doc.PageSetting.Width = 257 'B4纸张宽度,单位为毫米
    doc.PageSetting.Height = 364  'B4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(4) Then
    doc.PageSetting.Width = 176 'B5纸张宽度,单位为毫米
    doc.PageSetting.Height = 250  'B5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(5) Then
    doc.PageSetting.Width = 420 'A2纸张宽度,单位为毫米
    doc.PageSetting.Height = 594  'A2纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(6) Then
    doc.PageSetting.Width = 105 'A6纸张宽度,单位为毫米
    doc.PageSetting.Height = 148  'A6纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("TextBox1").text IsNot Nothing And e.Form.Controls("TextBox2").text IsNot Nothing Then
    doc.PageSetting.Width = Val(e.Form.Controls("TextBox2").Value) '自定义纸张宽度,单位为毫米
    doc.PageSetting.Height = Val(e.Form.Controls("TextBox1").Value)  '自定义纸张高度,单位为毫米
Else
    messagebox.show("纸张规格不能为空")
    Return
End If
If e.Form.Controls("ComboBox2").Value Is Nothing Then
    messagebox.show("棋赛名称不能为空")
    Return
End If
Dim cont As Integer = DataTables("基本信息").SQLCompute("Count(姓名)","[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
If e.Form.Controls("ComboBox7").Value Is Nothing Then
    messagebox.show("身份不能为空")
    Return
ElseIf e.Form.Controls("ComboBox7").Value = "裁判" And cont = 0 Then
    messagebox.show("没有裁判基本信息")
    Return
End If
Dim c1 As Double = e.Form.Controls("TextBox4").Value
Dim c2 As Double = e.Form.Controls("TextBox5").Value
Dim c3 As Double = Val(doc.PageSetting.Width)
Dim c4 As Double = Val(doc.PageSetting.Height)
Doc.PageSetting.LeftMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置左边距
Doc.PageSetting.RightMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置右边距
Doc.PageSetting.TopMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置上边距
Doc.PageSetting.BottomMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置下边距
For i As Integer = 0 To cont - 1
    Dim rt As New prt.RenderTable() '定义一个表格对象
    Dim drs As List(Of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
    If drs IsNot Nothing Then
        rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
        rt.Style.GridLines.Horz = new Prt.LineDef(Color.white)
        rt.Style.GridLines.Vert = new Prt.LineDef(Color.white)
        rt.Width = c1 '表格宽度为
        rt.Height = c2
        rt.Style.Spacing.All = 2 '和其他对象之间的间隔为2mm
        rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
        rt.Rows.Count = 8 '设置总行数
        rt.Cols.Count = 7 '设置总列数
        rt.Rows(0).Height = 8
        rt.Cols(0).Width = 3
        rt.cells(0,0).SpanCols = 7
        rt.cells(1,1).SpanCols = 5
        rt.Rows(1).Height = 10
        rt.Cells(1,1).Style.FontBold = True
        rt.Cells(1,1).Style.FontName = e.Form.Controls("FontPicker1").Value
        rt.Cells(1,1).Style.FontSize = e.Form.Controls("ComboBox3").Value
        rt.cells(1,1).Text = e.Form.Controls("ComboBox2").text
        e.Form.Controls("ComboBox2").Theme = "(none)"
        e.Form.Controls("ComboBox2").ForeColor = e.Form.Controls("FontPicker1").Value
        rt.cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(1,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Cells(2,1).SpanCols = 5
        If drs(i).IsNull("棋赛副名") Then
            rt.Cells(2,1).Text = Nothing
            rt.Rows(2).Height = 5
        Else
            rt.Cells(2,1).Text = drs(i)("棋赛副名")
            drs(i)("棋赛副名").Theme = "(none)"
            drs(i)("棋赛副名").ForeColor = e.Form.Controls("FontPicker2").Value
        End If
        rt.Cells(2,1).Style.FontName = e.Form.Controls("FontPicker2").Value
        rt.Cells(2,1).Style.FontSize = e.Form.Controls("ComboBox4").Value
        rt.Cells(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(2,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(3).Height = 2
        rt.Cols(3).Width = 37
        rt.Rows(4).Height = 25
        If e.Form.Controls("ComboBox7").text = "参赛人" Then
            rt.Cells(4,3).Text = drs(i)("编号")
        ElseIf e.Form.Controls("ComboBox7").text = "裁判" Then
            rt.Cells(4,3).Text = "裁判"
        End If
            e.Form.Controls("ComboBox7").Theme = "(none)"
            e.Form.Controls("ComboBox7").ForeColor = e.Form.Controls("FontPicker3").Value
        rt.Cells(4,3).Style.FontName = e.Form.Controls("FontPicker3").Value
        rt.Cells(4,3).Style.FontSize = e.Form.Controls("ComboBox5").Value
        rt.Cells(4,3).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(4,3).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(5).Height = 2
        rt.cells(6,2).SpanCols = 3
        rt.Cells(6,2).Text= drs(i)("姓名")
        drs(i)("姓名").Theme = "(none)"
        drs(i)("姓名").ForeColor = e.Form.Controls("FontPicker4").Value
        rt.Cells(6,2).Style.FontName = e.Form.Controls("FontPicker4").Value
        rt.Cells(6,2).Style.FontSize = e.Form.Controls("ComboBox6").Value
        rt.Cells(6,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(6,2).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.cells(7,0).SpanCols = 7
        rt.Rows(7).Height = 8
        rt.Cols(6).Width = 3
        doc.Body.Children.Add(rt) '将表格对象加入到报表中
    Else
        Return
    End If
Next
Doc.Preview() '预览报表

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/11 22:01:00 [显示全部帖子]

窗口Afterload事件默认颜色设置:
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 棋赛名称,比赛已结束 Fr om {基本信息} WHERE [比赛已结束] = False Or [比赛已结束] Is null"
dt = cmd.ExecuteReader
If dt IsNot Nothing Then
    Dim qsmc As WinForm.ComboBox = e.form.Controls("ComboBox2")
    qsmc.Combolist = dt.SQLGetComboListString("棋赛名称","[比赛已结束] = False Or [比赛已结束] Is null")
End If
e.Form.Controls("FontPicker1").Value = "华文楷体"
e.Form.Controls("FontPicker1").ForeColor = Color.Black
e.Form.Controls("ComboBox3").Value = 18
e.Form.Controls("FontPicker2").Value = "华文楷体"
e.Form.Controls("FontPicker2").ForeColor = Color.Black
e.Form.Controls("ComboBox4").Value = 12
e.Form.Controls("FontPicker3").Value = "华文楷体"
e.Form.Controls("FontPicker3").Value = Color.Black
e.Form.Controls("ComboBox5").Value = 72
e.Form.Controls("FontPicker4").Value = "华文楷体"
e.Form.Controls("FontPicker4").Value = Color.Black
e.Form.Controls("ComboBox6").Value = 28


 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/14 12:38:00 [显示全部帖子]

报错:
.NET Framework 版本:4.0.30319.18063
Foxtable 版本:2021.12.12.12
错误所在事件:窗口,胸牌排版,Button1,Click
详细错误信息:
Public member 'Theme' on type 'String' not found.


Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
If e.Form.Controls("TextBox4").Value Is Nothing OrElse e.Form.Controls("TextBox5").Value Is Nothing Then
    messagebox.show("模板长宽不能为空")
    Return
End If
If e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(0) Then
    doc.PageSetting.Width = 297 'A3纸张宽度,单位为毫米
    doc.PageSetting.Height = 420  'A3纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(1) Then
    doc.PageSetting.Width = 210 'A4纸张宽度,单位为毫米
    doc.PageSetting.Height = 297  'A4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(2) Then
    doc.PageSetting.Width = 148.5 'A5纸张宽度,单位为毫米
    doc.PageSetting.Height = 210  'A5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(3) Then
    doc.PageSetting.Width = 257 'B4纸张宽度,单位为毫米
    doc.PageSetting.Height = 364  'B4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(4) Then
    doc.PageSetting.Width = 176 'B5纸张宽度,单位为毫米
    doc.PageSetting.Height = 250  'B5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(5) Then
    doc.PageSetting.Width = 420 'A2纸张宽度,单位为毫米
    doc.PageSetting.Height = 594  'A2纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(6) Then
    doc.PageSetting.Width = 105 'A6纸张宽度,单位为毫米
    doc.PageSetting.Height = 148  'A6纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("TextBox1").text IsNot Nothing And e.Form.Controls("TextBox2").text IsNot Nothing Then
    doc.PageSetting.Width = Val(e.Form.Controls("TextBox2").Value) '自定义纸张宽度,单位为毫米
    doc.PageSetting.Height = Val(e.Form.Controls("TextBox1").Value)  '自定义纸张高度,单位为毫米
Else
    messagebox.show("纸张规格不能为空")
    Return
End If
If e.Form.Controls("ComboBox2").Value Is Nothing Then
    messagebox.show("棋赛名称不能为空")
    Return
End If
Dim cont As Integer = DataTables("基本信息").SQLCompute("Count(姓名)","[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
If e.Form.Controls("ComboBox7").Value Is Nothing Then
    messagebox.show("身份不能为空")
    Return
ElseIf e.Form.Controls("ComboBox7").Value = "裁判" And cont = 0 Then
    messagebox.show("没有裁判基本信息")
    Return
End If
Dim c1 As Double = e.Form.Controls("TextBox4").Value
Dim c2 As Double = e.Form.Controls("TextBox5").Value
Dim c3 As Double = Val(doc.PageSetting.Width)
Dim c4 As Double = Val(doc.PageSetting.Height)
Doc.PageSetting.LeftMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置左边距
Doc.PageSetting.RightMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置右边距
Doc.PageSetting.TopMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置上边距
Doc.PageSetting.BottomMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置下边距
For i As Integer = 0 To cont - 1
    Dim rt As New prt.RenderTable() '定义一个表格对象
    Dim drs As List(Of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
    If drs IsNot Nothing Then
        rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
        rt.Style.GridLines.Horz = new Prt.LineDef(Color.white)
        rt.Style.GridLines.Vert = new Prt.LineDef(Color.white)
        rt.Width = c1 '表格宽度为
        rt.Height = c2
        rt.Style.Spacing.All = 2 '和其他对象之间的间隔为2mm
        rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
        rt.Rows.Count = 8 '设置总行数
        rt.Cols.Count = 7 '设置总列数
        rt.Rows(0).Height = 8
        rt.Cols(0).Width = 3
        rt.cells(0,0).SpanCols = 7
        rt.cells(1,1).SpanCols = 5
        rt.Rows(1).Height = 10
        rt.Cells(1,1).Style.FontBold = True
        e.Form.Controls("ComboBox2").Theme = "(none)"
        rt.Cells(1,1).Style.FontName = e.Form.Controls("FontPicker1").Value
        rt.Cells(1,1).Style.TextColor = e.Form.Controls("ColorPicker1").Value
        rt.Cells(1,1).Style.FontSize = e.Form.Controls("ComboBox3").Value
        rt.cells(1,1).Text = e.Form.Controls("ComboBox2").text
        rt.cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(1,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Cells(2,1).SpanCols = 5
        If drs(i).IsNull("棋赛副名") Then
            rt.Cells(2,1).Text = Nothing
            rt.Rows(2).Height = 5
        Else
            rt.Cells(2,1).Text = drs(i)("棋赛副名")
            drs(i)("棋赛副名").Theme = "(none)"
        End If
        rt.Cells(2,1).Style.FontName = e.Form.Controls("FontPicker2").Value
        rt.Cells(2,1).Style.TextColor = e.Form.Controls("ColorPicker2").Value
        rt.Cells(2,1).Style.FontSize = e.Form.Controls("ComboBox4").Value
        rt.Cells(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(2,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(3).Height = 2
        rt.Cols(3).Width = 37
        rt.Rows(4).Height = 25
        If e.Form.Controls("ComboBox7").text = "参赛人" Then
            rt.Cells(4,3).Text = drs(i)("编号")
        ElseIf e.Form.Controls("ComboBox7").text = "裁判" Then
            rt.Cells(4,3).Text = "裁判"
        End If
        e.Form.Controls("ComboBox7").Theme = "(none)"
        rt.Cells(4,3).Style.FontName = e.Form.Controls("FontPicker3").Value
        rt.Cells(4,3).Style.TextColor = e.Form.Controls("ColorPicker3").Value
        rt.Cells(4,3).Style.FontSize = e.Form.Controls("ComboBox5").Value
        rt.Cells(4,3).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(4,3).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(5).Height = 2
        rt.cells(6,2).SpanCols = 3
        rt.Cells(6,2).Text= drs(i)("姓名")
        drs(i)("姓名").Theme = "(none)"
        rt.Cells(6,2).Style.FontName = e.Form.Controls("FontPicker4").Value
        rt.Cells(6,2).Style.TextColor = e.Form.Controls("ColorPicker4").Value
        rt.Cells(6,2).Style.FontSize = e.Form.Controls("ComboBox6").Value
        rt.Cells(6,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(6,2).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.cells(7,0).SpanCols = 7
        rt.Rows(7).Height = 8
        rt.Cols(6).Width = 3
        doc.Body.Children.Add(rt) '将表格对象加入到报表中
    Else
        Return
    End If
Next
Doc.Preview() '预览报表

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/14 14:25:00 [显示全部帖子]

代码在按钮上,表是临时生成的,不存在drawcell事件,把按钮代码改为这样直接报错:
        rt.Cells(6,2).Style.ForeColor = e.Form.Controls("ColorPicker4").Value


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20211214142635.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2021/12/14 14:28:18编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/14 14:52:00 [显示全部帖子]

不是设置单元格显示颜色,是设置字体颜色。

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/15 11:06:00 [显示全部帖子]

临时表要在窗口中执行按钮事件才生成,字体的颜色设置在全局表中怎样定义、控制?
[此贴子已经被作者于2021/12/15 11:39:19编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/15 11:38:00 [显示全部帖子]

代码在窗口按钮里,通过代码生成打印表,全局表代码中能先判断表是否已经生成,然后设置颜色设置?

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/15 15:22:00 [显示全部帖子]

在用窗口按钮生成的表中设置字体颜色。

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/15 19:27:00 [显示全部帖子]

下面这段代码不报错,但只显示几个边框,没文本内容。
[此贴子已经被作者于2021/12/15 20:01:02编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1882 积分:10391 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/15 19:28:00 [显示全部帖子]

Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
If e.Form.Controls("TextBox4").Value Is Nothing OrElse e.Form.Controls("TextBox5").Value Is Nothing Then
    messagebox.show("模板长宽不能为空")
    Return
End If
If e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(0) Then
    doc.PageSetting.Width = 297 'A3纸张宽度,单位为毫米
    doc.PageSetting.Height = 420  'A3纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(1) Then
    doc.PageSetting.Width = 210 'A4纸张宽度,单位为毫米
    doc.PageSetting.Height = 297  'A4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(2) Then
    doc.PageSetting.Width = 148.5 'A5纸张宽度,单位为毫米
    doc.PageSetting.Height = 210  'A5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(3) Then
    doc.PageSetting.Width = 257 'B4纸张宽度,单位为毫米
    doc.PageSetting.Height = 364  'B4纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(4) Then
    doc.PageSetting.Width = 176 'B5纸张宽度,单位为毫米
    doc.PageSetting.Height = 250  'B5纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(5) Then
    doc.PageSetting.Width = 420 'A2纸张宽度,单位为毫米
    doc.PageSetting.Height = 594  'A2纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton2").Checked = True And e.Form.Controls("ComboBox1").text = e.form.controls("combobox1").items(6) Then
    doc.PageSetting.Width = 105 'A6纸张宽度,单位为毫米
    doc.PageSetting.Height = 148  'A6纸张高度,单位为毫米
ElseIf e.Form.Controls("RadioButton1").Checked = True And e.Form.Controls("TextBox1").text IsNot Nothing And e.Form.Controls("TextBox2").text IsNot Nothing Then
    doc.PageSetting.Width = Val(e.Form.Controls("TextBox2").Value) '自定义纸张宽度,单位为毫米
    doc.PageSetting.Height = Val(e.Form.Controls("TextBox1").Value)  '自定义纸张高度,单位为毫米
Else
    messagebox.show("纸张规格不能为空")
    Return
End If
If e.Form.Controls("ComboBox2").Value Is Nothing Then
    messagebox.show("棋赛名称不能为空")
    Return
End If
Dim cont As Integer = DataTables("基本信息").SQLCompute("Count(姓名)","[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
If e.Form.Controls("ComboBox7").Value Is Nothing Then
    messagebox.show("身份不能为空")
    Return
ElseIf e.Form.Controls("ComboBox7").Value = "裁判" And cont = 0 Then
    messagebox.show("没有裁判基本信息")
    Return
End If
Dim c1 As Double = e.Form.Controls("TextBox4").Value
Dim c2 As Double = e.Form.Controls("TextBox5").Value
Dim c3 As Double = Val(doc.PageSetting.Width)
Dim c4 As Double = Val(doc.PageSetting.Height)
Doc.PageSetting.LeftMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置左边距
Doc.PageSetting.RightMargin = (c3 - c1*(Math.Floor(c3/c1)))/2 '设置右边距
Doc.PageSetting.TopMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置上边距
Doc.PageSetting.BottomMargin = (c4 - c2*(Math.Floor(c4/c2)))/2 '设置下边距
For i As Integer = 0 To cont - 1
    Dim rt As New prt.RenderTable() '定义一个表格对象
    Dim drs As List(Of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = '" & e.Form.Controls("ComboBox2").text & "' And [身份] = '" & e.Form.Controls("ComboBox7").text & "'")
    If drs IsNot Nothing Then
        rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
        rt.Style.GridLines.Horz = new Prt.LineDef(Color.white)
        rt.Style.GridLines.Vert = new Prt.LineDef(Color.white)
        rt.Width = c1 '表格宽度为
        rt.Height = c2
        rt.Style.Spacing.All = 2 '和其他对象之间的间隔为2mm
        rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
        rt.Rows.Count = 8 '设置总行数
        rt.Cols.Count = 7 '设置总列数
        rt.Rows(0).Height = 8
        rt.Cols(0).Width = 3
        rt.cells(0,0).SpanCols = 7
        rt.cells(1,1).SpanCols = 5
        rt.Rows(1).Height = 10
        rt.cells(1,1).Text = e.Form.Controls("ComboBox2").text
        rt.Cells(1,1).Style.FontBold = True
        'e.Form.Controls("ComboBox2").Theme = "(none)"
        rt.Cells(1,1).Style.FontName = e.Form.Controls("FontPicker1").Value
        rt.Cells(1,1).Style.TextColor = e.Form.Controls("ColorPicker1").Value
        rt.Cells(1,1).Style.FontSize = e.Form.Controls("ComboBox3").Value
        rt.cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(1,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Cells(2,1).SpanCols = 5
        If drs(i).IsNull("棋赛副名") Then
            rt.Cells(2,1).Text = Nothing
            rt.Rows(2).Height = 5
        Else
            rt.Cells(2,1).Text = drs(i)("棋赛副名")
            'drs(i)("棋赛副名").Theme = "(none)"
        End If
        rt.Cells(2,1).Style.FontName = e.Form.Controls("FontPicker2").Value
        rt.Cells(2,1).Style.TextColor = e.Form.Controls("ColorPicker2").Value
        rt.Cells(2,1).Style.FontSize = e.Form.Controls("ComboBox4").Value
        rt.Cells(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(2,1).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(3).Height = 2
        rt.Cols(3).Width = 37
        rt.Rows(4).Height = 25
        If e.Form.Controls("ComboBox7").text = "参赛人" Then
            rt.Cells(4,3).Text = drs(i)("编号")
        ElseIf e.Form.Controls("ComboBox7").text = "裁判" Then
            rt.Cells(4,3).Text = "裁判"
        End If
        'e.Form.Controls("ComboBox7").Theme = "(none)"
        rt.Cells(4,3).Style.FontName = e.Form.Controls("FontPicker3").Value
        rt.Cells(4,3).Style.TextColor = e.Form.Controls("ColorPicker3").Value
        rt.Cells(4,3).Style.FontSize = e.Form.Controls("ComboBox5").Value
        rt.Cells(4,3).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(4,3).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.Rows(5).Height = 2
        rt.cells(6,2).SpanCols = 3
        rt.Cells(6,2).Text= drs(i)("姓名")
        'drs(i)("姓名").Theme = "(none)"
        rt.Cells(6,2).Style.FontName = e.Form.Controls("FontPicker4").Value
        rt.Cells(6,2).Style.TextColor = e.Form.Controls("ColorPicker4").Value
        rt.Cells(6,2).Style.FontSize = e.Form.Controls("ComboBox6").Value
        rt.Cells(6,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.cells(6,2).Style.TextAlignVert = prt.AlignHorzEnum.Center
        rt.cells(7,0).SpanCols = 7
        rt.Rows(7).Height = 8
        rt.Cols(6).Width = 3
        doc.Body.Children.Add(rt) '将表格对象加入到报表中
    Else
        Return
    End If
Next
Doc.Preview() '预览报表
[此贴子已经被作者于2021/12/15 20:02:00编辑过]

 回到顶部
总数 16 1 2 下一页