获取所有项目的名称,并在列表框中计算项目数

时间:2016-11-12 00:30:24

标签: .net vb.net listbox listboxitem

Okey ..这是一个代码,或类似的东西。

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    noselect = True
    'dim-eli a KS-t(keres/kinalt) aszerint,hogy,mi van select-elve 
    If RadioButton1.Checked Then
        ks = "Kínál"
    Else
        ks = "Keres"
    End If

    'count-ol -1-tol a listbox1.items.count-ig(pl 4)


    kód.RichTextBox1.Text = "[hr][img]http://kepfeltoltes.hu/160512/seeadfix_www.kepfeltoltes.hu_.png[/img][hr][table]" & vbNewLine &
        vbNewLine & "[tr][td][b][color=#7CC576]Név:" & vbNewLine & "[/td][td][b][color=white]" & TextBox1.Text & vbNewLine & "[/td][/tr]" & vbNewLine &
        vbNewLine & "[tr][td][b][color=#7CC576]Elérhetőség:" & vbNewLine & "[/td][td][b][color=white]" & TextBox3.Text & vbNewLine & "[/td][/tr]" & vbNewLine &
        vbNewLine & "[tr][td][b][color=#7CC576]Kínál/Keres:" & vbNewLine & "[/td][td][b][color=white]" & ks & vbNewLine & "[/color][/td][/tr]" & vbNewLine &
    vbNewLine & "[tr][td][b][color=#7CC576]Megnevezés:" & vbNewLine & "[/td][td][b][color=white]" & TextBox4.Text & vbNewLine & "[/td][/tr]" & vbNewLine &
    vbNewLine & "[tr][td][b][color=#7CC576]Képek:"
    noselect = False
    For l_index As Integer = 0 To (ListBox1.Items.Count - 1)
        kód.RichTextBox1.Text += vbNewLine & "[img width=1280 high=720]" & --- & vbNewLine

    Next

    kód.Show()

End Sub

所以,我想要的: 我想将此文kód.RichTextBox1.Text += vbNewLine & "[img width=1280 high=720]" & -)添加到我的kod.richtextbox,与listbox1.items.count一样多。

1 个答案:

答案 0 :(得分:2)

我猜你想要将列表框的内容实际放入文本框中。试试这种方式:

For i As Integer = 0 To ListBox1.Items.Count - 1
  kód.RichTextBox1.AppendText(ListBox1.Items(i).ToString & Environment.NewLine)
Next

或For Each循环:

For Each s As String In ListBox1.Items
  kód.RichTextBox1.AppendText(s & Environment.NewLine)
Next