开发者

display selectedItems in a label

I need to display t开发者_开发技巧he selecteditems in a label I am using VB 2005 I set the selection mode to multi-extended It did work selecting only one item with the following code: me.xresultslabel.text= me.xlisttextbox.text.selectedItem.tostring

But when I tried to display more than one item using the following code: me.resultlabel.text= me.xlisttextbox.text.selectedItems, I get the following string on the label: system.windows.forms.listbox+selectedobjetcollections.

any help will be highly appreciate


    Dim collection = Me.xlisttextbox.Text.SelectedItems
    Dim builder As New StringBuilder()

    For i As Integer = 0 To collection.Count - 1
        If i > 0 Then builder.Append(", ")
        builder.Append(collection(i))
    Next

    Me.resultlabel.Text = builder.ToString
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜