有没有办法从CheckedListBox获取所选项目列表以在SQL表达式中使用它?我为CheckedListBox
填充了列名(.DisplayMember = "COLUMN_NAME", .ValueMember = "COLUMN_NAME")
,并希望用户只选择要导出到Excel的列。我只需要选择例如Name, ID, Number
来使用SELECT Name, ID, Number FROM ...
答案 0 :(得分:0)
If CheckedListBox.SelectedItems.Count <> 0 Then
Dim columns = String.Join(",", CheckedListBox.CheckedItems.Cast(Of String))
Dim query = String.Format("SELECT {0} FROM ..", columns)
'Proceed
Else
'Prompt user to select columns
End If