以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- ListView过滤后按顺序逐个显示 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=178684) |
-- 作者:sysckj -- 发布时间:2022/7/15 17:35:00 -- ListView过滤后按顺序逐个显示 Dim cnt As Integer = DataTables("参与人员").DataRows.Count Dim Val As Double = cnt*0.05 Dim Lng As Long = Math.Ceiling(Val) Tables("参与人员").StopRedraw() Dim nds As Integer = Lng \'要抽取的记录数 DataTables("参与人员").ReplaceFor("录取状态",False) Do Dim idx As Integer = rand.Next(0,cnt) Dim dr As DataRow = DataTables("参与人员").DataRows(idx) If dr("录取状态") = False Then dr("录取状态") = True dr("录取编号") = lng - nds + 1 nds = nds - 1 End If Loop While nds > 0 Tables("参与人员").Filter = "[录取状态] = True" Tables("参与人员").Refresh Dim lvw As WinForm.ListView = e.Form.Controls("ListView1") lvw.View = ViewMode.Tile \'显示模式为平铺 Dim cls() As String = {"姓名","录取编号"} \'定义列名 For i As Integer = 0 To cls.Length - 1 \'增加列 Dim c As WinForm.ListViewColumn = lvw.Columns.Add() c.Name = cls(i) \'指定列名 Next For Each dr As DataRow In DataTables("参与人员").DataRows \'从数据表中提取数据 If dr("录取状态") = True And dr("录取编号") <> "Null" End If Dim vr As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 Dim lqbh As String = dr("录取编号") \'获取此学生的录取编号 For Each cl As String In cls \'逐列取值 vr(cl) = dr(cl) Next Next 我只想显示录取状态为true并且有录取编号的信息,显示顺序按录取编号从小到大显示出来,请问大佬该如何修改代码。
|
-- 作者:有点蓝 -- 发布时间:2022/7/16 8:43:00 -- For Each dr As DataRow In DataTables("参与人员").select("[录取状态] = True","录取编号")\'从数据表中提取数据 Dim vr As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 Dim lqbh As String = dr("录取编号") \'获取此学生的录取编号 For Each cl As String In cls \'逐列取值 vr(cl) = dr(cl) Next Next
|