以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]checklistbox控件赋值问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=192271) |
-- 作者:riyuan -- 发布时间:2024/6/8 21:46:00 -- [求助]checklistbox控件赋值问题 请教当选择当前行时,如何把表中的军人类别的值赋值到checklistbox控件,根据数据让checklistbox选中相应的值 |
-- 作者:有点蓝 -- 发布时间:2024/6/10 21:06:00 -- http://www.foxtable.com/webhelp/topics/0951.htm、http://www.foxtable.com/webhelp/topics/0216.htm dim ss() as string = tabels("表A").current("军人类别").split(",") Dim lst As WinForm.CheckedListBox lst = Forms("窗口1").Controls("CheckedListBox1") For Index As Integer = 0 To lst.Items.Count - 1 if Array.Indexof(ss, lst.Items(Index )) > -1 lst.SetItemChecked(Index, True) end if
Next |
-- 作者:riyuan -- 发布时间:2024/6/11 16:54:00 -- 此主题相关图片如下:screenshot-1718095879399.png 为什么在选择当前行的时候,不显示荣誉称号的选择项,其他的都可以 [此贴子已经被作者于2024/6/11 16:54:49编辑过]
|
-- 作者:riyuan -- 发布时间:2024/6/11 16:56:00 -- If e.Table.Current Is Nothing Then \'如果Current为Nothing Return \'则返回 End If Dim r As Row = e.Table.Current Dim t1 As Table = Tables("cjxx_Table1") Dim xm, sfz, zzmm, bddh As String Dim rwsj, twsj As String xm = e.Form.Controls("xm").Text sfz = e.Form.Controls("sfz").Text zzmm = e.Form.Controls("zzmm").Text bddh = e.Form.Controls("bddh").Text rwsj = CStr(e.Form.Controls("rwsj").text) twsj = cstr(e.Form.Controls("twsj").text) Dim lst As WinForm.CheckedListBox Dim lst1 As WinForm.CheckedListBox Dim lst2 As WinForm.CheckedListBox lst = e.Form.Controls("rylb") lst1 = e.Form.Controls("zs") lst2 = e.Form.Controls("ps") Dim cmd As New SQLCommand cmd.C Dim dt As DataTable e.Form.Controls("xm").Text = r("姓名") e.Form.Controls("sfz").Text = r("身份证号") e.Form.Controls("zzmm").Text = r("政治面貌") e.Form.Controls("bddh").Text = r("部队代号") e.Form.Controls("rwsj").Text = r("入伍时间") e.Form.Controls("twsj").Text = r("退伍时间") Dim ss() As String = t1.current("军人类别").split(",") For Index As Integer = 0 To lst.Items.Count - 1 lst.SetItemChecked(Index, False) If Array.Indexof(ss, lst.Items(Index)) > -1 Then lst.SetItemChecked(Index, True) End If Next Dim ss1() As String = t1.current("战时战功").split(",") For Index1 As Integer = 0 To lst1.Items.Count - 1 lst1.SetItemChecked(Index1, False) If Array.Indexof(ss1, lst1.Items(Index1)) > -1 Then lst1.SetItemChecked(Index1, True) End If Next Dim ss2() As String = t1.current("平时战功").split(",") For Index2 As Integer = 0 To lst2.Items.Count - 1 lst2.SetItemChecked(Index2, False) If Array.Indexof(ss2, lst2.Items(Index2)) > -1 Then lst2.SetItemChecked(Index2, True) End If Next
|
-- 作者:riyuan -- 发布时间:2024/6/11 16:57:00 -- 一等功、二等功、三等功和人员类别都可以正常显示 ,就中人有荣誉称号不行 |
-- 作者:有点蓝 -- 发布时间:2024/6/11 17:15:00 -- 可能数据有问题,调试看看 msgbox(t1.current("战时战功")) Dim ss1() As String = t1.current("战时战功").split(",") For Index1 As Integer = 0 To lst1.Items.Count - 1 lst1.SetItemChecked(Index1, False) msgbox(Array.Indexof(ss1, lst1.Items(Index1))) If Array.Indexof(ss1, lst1.Items(Index1)) > -1 Then lst1.SetItemChecked(Index1, True) End If Next |
-- 作者:riyuan -- 发布时间:2024/6/12 8:51:00 -- 测试了一下,显示的是荣誉称号和-1 |
-- 作者:riyuan -- 发布时间:2024/6/12 8:52:00 -- 此主题相关图片如下:2.png 此主题相关图片如下:1.png 测试了一下,显示的是荣誉称号和-1
|
-- 作者:有点蓝 -- 发布时间:2024/6/12 9:01:00 -- -1弹出了几次?lst1这个CheckedListBox应该有4个选项,那么-1应该至少弹出3次,在调试看看 msgbox("|" & t1.current("战时战功") & "|") Dim ss1() As String = t1.current("战时战功").split(",") msgbox("length=" & ss1.length) For Index1 As Integer = 0 To lst1.Items.Count - 1 lst1.SetItemChecked(Index1, False) msgbox(lst1.Items(Index1) & "=" & Array.Indexof(ss1, lst1.Items(Index1))) If Array.Indexof(ss1, lst1.Items(Index1)) > -1 Then lst1.SetItemChecked(Index1, True) End If Next |
-- 作者:riyuan -- 发布时间:2024/6/12 9:07:00 -- -1弹出了4次 |