Dim cs() As String = {"批次", "序号"}
Dim cr As Row = Tables("表A").Current
If cr IsNot Nothing AndAlso cr.Index < Tables("表A").Rows.Count - 1 Then
Dim nr As Row = Tables("表A").Rows(cr.Index + 1)
For Each c As String In cs
Dim temp As String = nr(c)
nr(c) = cr(c)
cr(c) = temp
Next
End If
这个代码,只移动了批次和序号,其它没动,把所有要移动的加到 {"批次", "序号"}这里,太多了,能优化一下吗!![dvubb](images/emot/em64.gif)
比如除了第一列,其它都移动,可以这样
If cr IsNot Nothing AndAlso cr.Index < Tables("表A").Rows.Count - 1 Then
Dim nr As Row = Tables("表A").Rows(cr.Index + 1)
For Each c As col In Tables("表A").cols
if c.name <> "第一列"
Dim temp As String = nr(c.name)
nr(c.name) = cr(c.name)
cr(c.name) = temp
end if
Next
End If
对了,老师,还有一个问题,上移或下移,左移或右移,连续调整的话,总是需要选中下调整,不然总是上下左右切换。能把最开始
![dvubb 图片点击可在新窗口打开查看](skins/default/filetype/jpg.gif)
此主题相关图片如下:5.jpg
![dvubb 图片点击可在新窗口打开查看](UploadFile/2024-5/202453110255051762.jpg)
选中的行连续调整吗,感谢老师!
![dvubb 图片点击可在新窗口打开查看](images/emot/em59.gif)
![dvubb 图片点击可在新窗口打开查看](images/emot/em59.gif)
![dvubb 图片点击可在新窗口打开查看](images/emot/em59.gif)
不是啊,比如我选中上楼的第四行,选中标志总是第四行啊,所以总是上下调整,我说明白了吗,谢谢!
If cr IsNot Nothing AndAlso cr.Index < Tables("表A").Rows.Count - 1 Then
Dim nr As Row = Tables("表A").Rows(cr.Index + 1)
For Each c As col In Tables("表A").cols
if c.name <> "第一列"
Dim temp As String = nr(c.name)
nr(c.name) = cr(c.name)
cr(c.name) = temp
end if
Next
Tables("表A").position = cr.Index + 1
End If
真牛,那左移或右移这样么Dim t As Table = Tables("填报表")
Dim r As Row = t.current
Dim n As Integer = t.colsel
Dim c As Col = t.cols(n)
If c.name Like "*专业_*" AndAlso not(c.name Like "第六专业_*") Then
If c.name Like "*_专业名称" Then
n = n -1
c = t.cols(n)
End If
Dim s1 As String = r(n+2)
Dim s2 As String = r(n+3)
r(n+2) = r(n)
r(n+3) = r(n+1)
r(n) = s1
r(n+1) = s2
Tables("表A").position = cr.Index + 1
End If
我自己都感觉不对啊![dvubb 图片点击可在新窗口打开查看](images/emot/em59.gif)