以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 【求助】AddUserStyle 代码设置格式应用无效 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144846) |
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 14:19:00 -- 【求助】AddUserStyle 代码设置格式应用无效 窗口表类型 SQLQuery 窗口打开表设置的代码 Tables(e.form.name & "_Table1").Fill ("S elect [工序],[工序承诺期],[单号],[员工姓名],数量,金额 From [今日计划明细] where 工序= \'" & Vars("gxmc") & "\' And DateDiff(dd,工序承诺期,getdate())>=0","zzkb",True) \'从数据库取数 Tables(e.form.name & "_Table1").SetColVisibleWidth("工序|100|工序承诺期|150|单号|190|员工姓名|100|数量|100|金额|20") \'列宽 Tables(e.form.name & "_Table1").Font = new font ("微软雅黑",16,fontstyle.bold) \'字体大小 Tables(e.form.name & "_Table1").DefaultRowHeight = 61 \'行高 Tables(e.form.name & "_Table1").ExtendLastCol = True \'自动调整最后一列的宽度,以适用表宽 Tables(e.form.name & "_Table1").SetHeaderRowHeight(50) \'标题行高ExtendLastCol Tables(e.form.name & "_Table1").UseVisualStyle = False \'关闭界面风格 Tables(e.form.name & "_Table1").DataTable.SysStyles("SelectedColumnHeader").backColor = Color.white \'选中列标题区的背景颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("SelectedRowHeader").BackColor = Color.White \'选中列标题区的背景颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Focus").backColor = Color.white \'焦点单元格的背景颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Focus").ForeColor = Color.blue \'焦点单元格的字体颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Normal").BackColor = Color.white \'数据区背景颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Normal").foreColor = Color.blue \'据区字体颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Fixed").foreColor = Color.red \'指定标题区的字体颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("EmptyArea").BackColor = Color.white \'空白区背景颜色 Tables(e.form.name & "_Table1").DataTable.SysStyles("Fixed").backColor = Color.white \'指定标题区的背景颜色 Tables(e.form.name & "_Table1").Cols("工序").TextAlign = HorizontalAlignment.Center \'文本居中对齐 Tables(e.form.name & "_Table1").Cols("工序承诺期").TextAlign = HorizontalAlignment.Center \'文本居中对齐 Tables(e.form.name & "_Table1").Cols("单号").TextAlign = HorizontalAlignment.Center \'文本居中对齐 Tables(e.form.name & "_Table1").Cols("员工姓名").TextAlign = HorizontalAlignment.Center \'文本居中对齐 Tables(e.form.name & "_Table1").Cols("数量").TextAlign = HorizontalAlignment.Center \'文本居中对齐 Tables(e.form.name & "_Table1").Cols("金额").TextAlign = HorizontalAlignment.Center \'文本居中对齐 \'MessageBox.Show(8) With DataTables(e.form.name & "_Table1") .LoadFilter = "工序= \'" & Vars("gxmc") & "\' and DateDiff(dd,工序承诺期,getdate())>=0" \'清除加载条件 .LoadPage = 0 \'加载第一页 .LoadTop = 4 \'每页7行 .LoadOver = "id" .Load() e.Form.Controls("TextBox4").Value = (.LoadPage + 1) & "/" & .TotalPages \'显示页数状态 End With If Tables(e.form.name & "_Table1").rows.count < 4 Then Tables(e.form.name & "_Table1").addnew(4-Tables(e.form.name & "_Table1").rows.count) \'不够6行补6行 Tables(e.form.name & "_Table1").RowHeaderVisible = False \'隐藏行号列 DataTables(e.form.name & "_Table1").AddUserStyle("未派工", Color.Red, Color.White) DataTables(e.form.name & "_Table1").AddUserStyle("a", Color.Red, Color.White) DrawCell 代码 If e.Col.Name = "员工姓名" Then If e.Row("员工姓名") = "未派工" Then e.Style = "a" End If End If |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/31 14:24:00 -- 使用Fill的,到全局表事件drawcell写代码 |
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 14:36:00 -- 还是不行 DrawCell 全局表代码 Select Case e.Table.Name Case "工序数字化看板_Table1" If e.Col.Name = "员工姓名" Then If e.Row("员工姓名") = "未派工" Then e.Style = "a" End If End If End Select 工序数字化看板 窗口打开事件依旧为 |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/31 14:38:00 -- 开启DrawCell事件了吗? DataTables(e.form.name & "_Table1").AddUserStyle("a", Color.Red, Color.White) DataTables(e.form.name & "_Table1").GlobalHandler.DrawCell = True |
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 14:42:00 -- 开启了 依旧没有达到想要的效果 |
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 14:45:00 -- 是不是还需要在下一页代码内重新设置一下呢 |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/31 14:49:00 -- 做个例子发上来看看 |
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 15:20:00 -- 案例已经上传
|
||||
-- 作者:chen_sheng -- 发布时间:2019/12/31 15:38:00 -- 数据库备份在data文件夹 恢复就可以用哈 |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/31 15:52:00 -- "员工姓名" 列类型改为nvarchar(10),并把数据库里"员工姓名" 列里面多余的空格去掉。char和nchar类型是定长字段,长度不足数据库会自动补充空格的 |