以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]列标题设置失效  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=28618)

--  作者:zcw728909
--  发布时间:2013/2/5 13:52:00
--  [求助]列标题设置失效

有一个产品信息表,想让不同的用户组登录时,列标题动态改变,代码如下:

With DataTables("产品信息")
    Dim nmms() As String ={"电雕在制支数","机加在制支数","镀铜在制支数","车研在制支数","镀铬在制支数","料库在制支数","打样在制支数","印前在制支数","总检在制支数"}
    Dim nms() As String = {"电雕在制明细","机加在制明细","镀铜在制明细","车研在制明细","镀铬在制明细","料库在制明细","打样在制明细","印前在制明细","总检在制明细"}
    If _UserGroup <> "生产部" Then
        For Each nmm As String In nmms
            .DataCols(nmm).Caption = "在制支数"
            For Each nm As String In nms
                .DataCols(nm).Caption = "明细"
            Next
        Next
    Else

        For Each nmm As String In nmms
            .DataCols(nmm).Caption = Nothing
            For Each nm As String In nms
                .DataCols(nm).Caption = Nothing
            Next
        Next
    End If
End With

现在的问题是我以生产部登录时,列标题还是“在制支数”和“明细”,这是为什么?


--  作者:blackzhu
--  发布时间:2013/2/5 14:02:00
--  

BuildHeader

重新生成表头。


--  作者:zcw728909
--  发布时间:2013/2/5 14:09:00
--  
以下是引用blackzhu在2013-2-5 14:02:00的发言:

BuildHeader

重新生成表头。

这个方法应改放在代码的哪一段呢?

If _UserGroup <> "生产部" Then
        For Each nmm As String In nmms
            .DataCols(nmm).Caption = "在制支数"       

            .BuildHeader()

For Each nm As String In nms
                .DataCols(nm).Caption = "明细"

                .BuildHeader()
            Next
        Next
    Else

        For Each nmm As String In nmms
            .DataCols(nmm).Caption = Nothing

            .BuildHeader()
            For Each nm As String In nms
                .DataCols(nm).Caption = Nothing

                .BuildHeader()
            Next
        Next
    End If

这是我最开始放的地方,可是启动项目的时候总报错


--  作者:lin_hailun
--  发布时间:2013/2/5 14:32:00
--  

With DataTables("产品信息")
    Dim nmms() As String ={"电雕在制支数","机加在制支数","镀铜在制支数","车研在制支数","镀铬在制支数","料库在制支数","打样在制支数","印前在制支数","总检在制支数"}
    Dim nms() As String = {"电雕在制明细","机加在制明细","镀铜在制明细","车研在制明细","镀铬在制明细","料库在制明细","打样在制明细","印前在制明细","总检在制明细"}
    If _UserGroup <> "生产部" Then
        For Each nmm As String In nmms
            .DataCols(nmm).Caption = "在制支数"
        Next

       
        For Each nm As String In nms
            .DataCols(nm).Caption = "明细"
        Next

    Else

        For Each nmm As String In nmms
            .DataCols(nmm).Caption = Nothing
        Next

        For Each nm As String In nms
            .DataCols(nm).Caption = Nothing
        Next

    End If
    .BuildHeader()

End With


--  作者:zcw728909
--  发布时间:2013/2/5 15:39:00
--  
还是报错,我这个代码是自定义的一个内部函数,是放在项目事件Initialize中的,还是出现下面的错误
图片点击可在新窗口打开查看此主题相关图片如下:00.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2013-2-5 15:39:43编辑过]

--  作者:lin_hailun
--  发布时间:2013/2/5 15:47:00
--  
 把代码放在afterOpenproject事件里。
--  作者:zcw728909
--  发布时间:2013/2/5 16:52:00
--  
这次可以了