以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]请教一个代码怎么写; (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=75318) |
-- 作者:szoriental -- 发布时间:2015/10/5 9:03:00 -- [求助]请教一个代码怎么写; 有一个表,有编号列; 数字列1; 数字列2; 数字列3; 数字列4;如下: 编号列; 数字列1; 数字列2; 数字列3; 数字列4 0001 1 5 6 10 0002 2 3 8 20 0003 4 5 6 8
在窗口中做筛选,比如我输入数字“1”时,自动显示有“1”这个数字这一行的下一行(也就是0002行);输入数字“2”时,自动显示0003这一行;请教一下代码要怎么写? |
-- 作者:szoriental -- 发布时间:2015/10/5 10:30:00 -- 还没上班吗? |
-- 作者:xuezxz -- 发布时间:2015/10/5 20:41:00 -- Dim jh As List(of DataRow) = DataTables("表A").Select("数字列1 = 1") Dim flt As String For Each xh As DataRow In jh Dim i As Integer = Tables("表A").FindRow(xh) flt = flt & "," & Tables("表A").Rows(i+1)("编号列") Next flt = flt.trim(",") Tables("表A").Filter = "编号列 in (" & flt & ")" |
-- 作者:szoriental -- 发布时间:2015/10/6 23:01:00 -- 以下是引用xuezxz在2015/10/5 20:41:00的发言:
Dim jh As List(of DataRow) = DataTables("表A").Select("数字列1 = 1") Dim flt As String For Each xh As DataRow In jh Dim i As Integer = Tables("表A").FindRow(xh) flt = flt & "," & Tables("表A").Rows(i+1)("编号列") Next flt = flt.trim(",") Tables("表A").Filter = "编号列 in (" & flt & ")" 请教一下是在哪个控件的哪个事件里面写?
|
-- 作者:大红袍 -- 发布时间:2015/10/7 9:43:00 -- TextChanged事件
Dim jh As List(of DataRow) = DataTables("表A").Select("数字列1 = \'" & e.Sender.Text & "\'")
Dim flt As String
For Each xh As DataRow In jh
Dim i As Integer = Tables("表A").FindRow(xh)
flt = flt & "," & Tables("表A").Rows(i+1)("编号列")
Next
flt = flt.trim(",")
Tables("表A").Filter = "编号列 in (" & flt & ")"
|