Rss & SiteMap

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

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

标题:[求助]checklistbox控件赋值问题

1楼
riyuan 发表于:2024/6/8 21:46:00
请教当选择当前行时,如何把表中的军人类别的值赋值到checklistbox控件,根据数据让checklistbox选中相应的值

图片点击可在新窗口打开查看此主题相关图片如下:123.png
图片点击可在新窗口打开查看
2楼
有点蓝 发表于:2024/6/10 21:06:00
http://www.foxtable.com/webhelp/topics/0951.htmhttp://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(sslst.Items(Index )) > -1
    lst.SetItemChecked(Index, True)
end if
Next
3楼
riyuan 发表于:2024/6/11 16:54:00

图片点击可在新窗口打开查看此主题相关图片如下:screenshot-1718095879399.png
图片点击可在新窗口打开查看
为什么在选择当前行的时候,不显示荣誉称号的选择项,其他的都可以

[此贴子已经被作者于2024/6/11 16:54:49编辑过]
4楼
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
5楼
riyuan 发表于:2024/6/11 16:57:00
一等功、二等功、三等功和人员类别都可以正常显示 ,就中人有荣誉称号不行
6楼
有点蓝 发表于: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
7楼
riyuan 发表于:2024/6/12 8:51:00
测试了一下,显示的是荣誉称号和-1
8楼
riyuan 发表于:2024/6/12 8:52:00

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

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
测试了一下,显示的是荣誉称号和-1
9楼
有点蓝 发表于: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
10楼
riyuan 发表于:2024/6/12 9:07:00
-1弹出了4次

共21 条记录, 每页显示 10 条, 页签: [1] [2][3]

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

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