gpt4 book ai didi

vb.net - VB6 到 VBNet - ListBox.Selected

转载 作者:行者123 更新时间:2023-12-02 09:52:30 28 4
gpt4 key购买 nike

我当前有一个选择案例,它将从记录集中读取名称字段,并从该记录集中读取 bool 值,该值决定是否将该字段包含在稍后生成的报告中.

问题是,在 VB6 中,您可以将 bool 值分配给 ListBox.Selected(i)

现在,我无法弄清楚将其分配给什么,根据记录集中的 bool 值选择或不选择该字段。

代码:

Do Until rs_1.EOF
'Until we run out of records ...

str_FieldName = rs_1.Fields("FieldName").Value
b_IncludeField = rs_1.Fields("IncludeInBatchReport").Value

Select Case str_FieldName
Case "Sequence"
listbox_Fields.Items.Add("Sequence")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "BldgNo"
listbox_Fields.Items.Add("BldgNo")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "BldgName"
listbox_Fields.Items.Add("BldgName")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "BldgFunc"
listbox_Fields.Items.Add("BldgFunc")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "POC"
listbox_Fields.Items.Add("POC")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Phone"
listbox_Fields.Items.Add("Phone")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "AH_Phone"
listbox_Fields.Items.Add("AH_Phone")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Batch"
listbox_Fields.Items.Add("Batch")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Status"
listbox_Fields.Items.Add("Status")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Region_Req"
listbox_Fields.Items.Add("Region_Req")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Region_Alt"
listbox_Fields.Items.Add("Region_Alt")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Region_Fin"
listbox_Fields.Items.Add("Region_Fin")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
Case "Comments"
listbox_Fields.Items.Add("Comments")
listbox_Fields.SelectedItem(listbox_Fields.Items.Count - 1) = b_IncludeField
End Select

rs_1.MoveNext()

'... until we run out of records.
Loop

如您所见,我尝试了 SelectedItem,但这当然不起作用。

最佳答案

关于vb.net - VB6 到 VBNet - ListBox.Selected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11002736/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com