Foxtable(狐表)用户栏目专家坐堂 → 遍历指定列名数据


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

主题:遍历指定列名数据

帅哥哟,离线,有人找我吗?
ZJZK2018
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:767 积分:6119 威望:0 精华:0 注册:2018/2/1 17:26:00
遍历指定列名数据  发帖心情 Post By:2018/5/27 21:49:00 [只看该作者]

老师你好:
我的需求是:遍历指定列名数据,并按指定顺序进行排列,下面这代码出现了N个,如何处理?谢谢!

Dim dtb As DataTable = DataTables("试块取样")
Dim dr As Row = Tables("试块取样").Current
Dim nms() As String = {"品种种类","施工方量","供应商名称","设计强度","坍落度","试块留制_标准养护","试块留制_同条件养护","试块留制_拆模试块","取样人","见证人"}
Dim str As String

For Each dc As DataCol In dtb.DataCols
    For i As Integer = 0 To nms.Length - 1
        For Each nm As String In nms
            If dc.Name = nm AndAlso dr.IsNull(nm) = False Then
                str = str & dc.Name & ":" & dr(nms(i)) & ","
            End If
        Next
    Next
Next
MessageBox.Show(str)

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/27 22:43:00 [只看该作者]

Dim dtb As DataTable = DataTables("试块取样")
Dim dr As Row = Tables("试块取样").Current
Dim nms() As String = {"品种种类","施工方量","供应商名称","设计强度","坍落度","试块留制_标准养护","试块留制_同条件养护","试块留制_拆模试块","取样人","见证人"}
Dim str As String
For Each nm As String In nms
    If dr.IsNull(nm) = False Then
        str = str & nm & ":" & dr(nm) & ","
    End If
Next
MessageBox.Show(str)

 回到顶部