请教当选择当前行时,如何把表中的军人类别的值赋值到checklistbox控件,根据数据让checklistbox选中相应的值
此主题相关图片如下:123.png
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
此主题相关图片如下:screenshot-1718095879399.png
为什么在选择当前行的时候,不显示荣誉称号的选择项,其他的都可以
[此贴子已经被作者于2024/6/11 16:54:49编辑过]
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
一等功、二等功、三等功和人员类别都可以正常显示 ,就中人有荣誉称号不行
可能数据有问题,调试看看
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
-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