【发布时间】:2018-01-21 09:52:59
【问题描述】:
我有一个启用了 milti 选择的列表框,我试图根据选定的值创建一个 TSQL 命令,我从列表框中获取第一个选定的值,我如何获取其余选定的值。
Private Sub createSQLCMD(ByVal strServerName As String, ByVal
strDatabaseName As String, ByVal strTableName As String)
Dim strSQLCMD As String = "SELECT "
For i As Integer = 0 To lstFieldList.Items.Count - 1
If (lstFieldList.GetSelected(i)) And i < lstFieldList.Items.Count - 1 Then
strSQLCMD &= lstFieldList.SelectedValue.ToString & ","
End If
Next
strSQLCMD &= lstFieldList.SelectedValue.ToString
txtSQLCMD.Text = strSQLCMD & " FROM " & strTableName
End Sub
【问题讨论】:
-
ListBox类中实际上没有内置任何东西来做到这一点。有一个SelectedItems属性是单数SelectedItem的倍数,但没有SelectedValues等价于SelectedValue。 Check this out 寻求解决方案。