以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  动态样式  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=126980)

--  作者:漂亮美眉vszh
--  发布时间:2018/11/2 9:44:00
--  动态样式
1.在打开窗口时增加代码:\'DataTables(e.Form.name & "_Table1").AddUserStyle("Green", Color.Green,Color.black)
\'DataTables(e.Form.name & "_Table1").AddUserStyle("Pink", Color.Pink,Color.black)
\'DataTables(e.Form.name & "_Table1").AddUserStyle("DeepSkyBlue", Color.DeepSkyBlue,Color.black)
\'DataTables(e.Form.name & "_Table1").AddUserStyle("Red", Color.Red,Color.black)
2.动态生成报表,绑定报表
 Tables(e.Form.name & "_Table1").datasource = DataTables("项目开发进度汇总临时报表")

3.在DataTables(e.Form.name & "_Table1")的表属性内增加代码:
If e.Table.Rows.count > 0 Then
    If e.Table.Cols.Contains("阶段") Then
        Dim st As String
        If e.Col.Name = "阶段" OrElse e.Col.name = "任务名称" Then
        Else
            st = e.Row(e.Col.name)
            If st.Contains("未完成延期") Then
                e.Style = "Red"
            End If

        End If
    End If
End If


--  作者:漂亮美眉vszh
--  发布时间:2018/11/2 9:44:00
--  
请教老师,颜色未出来,不知道哪步写错了?


--  作者:有点甜
--  发布时间:2018/11/2 9:47:00
--  

动态绑定表的时候,这个表是【副本表】

 

Tables(e.Form.name & "_Table1").datasource = DataTables("项目开发进度汇总临时报表")

 

你要在表【项目开发进度汇总临时报表】的表属性写代码,或者【全局表事件】写代码才行。不能把代码写到窗口表事件


--  作者:漂亮美眉vszh
--  发布时间:2018/11/4 15:34:00
--  
第一步:.在打开窗口时增加代码:DataTables(e.Form.name & "_Table1").AddUserStyle("Green", Color.Green,Color.black)
DataTables(e.Form.name & "_Table1").AddUserStyle("Pink", Color.Pink,Color.black)
DataTables(e.Form.name & "_Table1").AddUserStyle("DeepSkyBlue", Color.DeepSkyBlue,Color.black)
DataTables(e.Form.name & "_Table1").AddUserStyle("Red", Color.Red,Color.black)
第二步,在项目表事件中加入以下代码
If e.Table.name = "5.6 项目开发进度汇总_table1" Then
    If e.Table.Cols.Contains("阶段") Then
        If e.Table.Rows.count > 0 Then
            Dim st As String
            If e.Col.Name = "阶段" OrElse e.Col.name = "任务名称" Then
            Else
                st = e.Row(e.Col.name)
                If st.Contains("未完成延期") Then
                    e.Style = "Red"
                End If
                
            End If
        End If
    End If
End If

可是还没有颜色,哪里写错了?

--  作者:有点甜
--  发布时间:2018/11/4 20:18:00
--  

绑定表格以后,再添加样式,开启事件,如

 

Tables(e.Form.name & "_Table1").datasource = DataTables("项目开发进度汇总临时报表")
Dim dt As DataTable = Tables(e.Form.name & "_Table1").DataTable
dt.AddUserStyle("Green", Color.Green,Color.black)
dt.AddUserStyle("Pink", Color.Pink,Color.black)
dt.AddUserStyle("DeepSkyBlue", Color.DeepSkyBlue,Color.black)
dt.AddUserStyle("Red", Color.Red,Color.black)
dt.GlobalHandler.DrawCell = True