我想以编程方式将CSV字符串与listbox绑定
Private Sub BindAttachmentsToListBox(ByVal collectionData As String)
Dim arrayString As String()
Dim separator As String() = {",", "\n", " "}
Dim attachmentList As New List(Of AttachmentModel)
arrayString = collectionData.ToString().Split(separator, StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To arrayString.Length - 1
Dim attachments As New AttachmentModel()
attachments.AttachmentID = Integer.Parse(arrayString(i).ToString().Trim())
attachments.AttachmentPath = arrayString(i + 1).ToString.Trim()
attachmentList.Add(attachments)
i = i + 1
Next
lbAttachments.DataSource = attachmentList
lbAttachments.DisplayMember = "AttachmentPath"
lbAttachments.ValueMember = "AttachmentID"
End Sub