Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共22 条记录, 每页显示 10 条, 页签: [1] [2][3]
[浏览完整版]

标题:[求助]选定单元格能连续左移和右移

1楼
tygzjsl 发表于:2024/5/30 21:06:00
大神老师,如何选定单元格能连续左移和右移,也就是能通过按钮点击能左移或右移,调整专业顺序,专业代码和专业名称一起移动,求按钮点击代码,感谢大神老师图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:123.jpg
图片点击可在新窗口打开查看

[此贴子已经被作者于2024/5/30 21:10:08编辑过]
2楼
有点蓝 发表于:2024/5/30 21:40:00
左移
dim t as table = tables("表A")
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-1)
r(n-2) = r(n)
r(n-1) = r(n+1)
r(n) = s1
r(n+1) = s2
end if
3楼
tygzjsl 发表于:2024/5/31 8:36:00
非常感谢老师,那么右移怎么改,全指望你啦图片点击可在新窗口打开查看
dim t as table = tables("表A")
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-1)
r(n-2) = r(n)
r(n-1) = r(n+1)
r(n) = s1
r(n+1) = s2
end if
4楼
tygzjsl 发表于:2024/5/31 8:38:00
然后老师你在帮我看一下这个呗

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20240530195938.jpg
图片点击可在新窗口打开查看
大神老师,想把除某些列外选定行连续上或下移动,按钮事件代码怎么改啊

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

要把选定行除批次和序号这两列外其它列内容能连续上移或下移(上移按钮和下移按钮事件),这个怎么改图片点击可在新窗口打开查看

5楼
有点蓝 发表于:2024/5/31 8:49:00
以下是引用tygzjsl在2024/5/31 8:36:00的发言:
非常感谢老师,那么右移怎么改,全指望你啦图片点击可在新窗口打开查看
左移的说明
dim t as table = tables("表A")
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-1) 上一个专业的专业名称
r(n-2) = r(n) 左移代码
r(n-1) = r(n+1) 左移专业名称
r(n) = s1 上一个专业代码右移
r(n+1) = s2 上一个专业名称右移
end if

根据上面说明,参照下图,自己思考右移应该怎么改

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
6楼
有点蓝 发表于:2024/5/31 8:51:00
以下是引用tygzjsl在2024/5/31 8:38:00的发言:
然后老师你在帮我看一下这个呗

要把选定行除批次和序号这两列外其它列内容能连续上移或下移(上移按钮和下移按钮事件),这个怎么改图片点击可在新窗口打开查看

参考:http://www.foxtable.com/webhelp/topics/1793.htm
http://www.foxtable.com/webhelp/topics/1846.htm
7楼
tygzjsl 发表于:2024/5/31 9:02:00
你真的是一个好老师!!!!图片点击可在新窗口打开查看
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
End If
8楼
tygzjsl 发表于:2024/5/31 9:25:00
With CurrentTable
    .Current.Move(.Position - 1)
End With
这个代码!但要除了批次和序号不动,只动其它怎么改,谢谢图片点击可在新窗口打开查看
9楼
有点蓝 发表于:2024/5/31 9:27:00
那就只能使用4楼的用法,这个用法有啥问题?
10楼
tygzjsl 发表于:2024/5/31 9:29:00
上移是这个代码
With CurrentTable
    .Current.Move(.Position - 1)
End With

下移是+1,但要除了批次和序号内容不动,只移动其它行内容怎么改,谢谢
共22 条记录, 每页显示 10 条, 页签: [1] [2][3]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03906 s, 2 queries.