vb.netdevexpress

VB.net display in textbox multiple values names with separate comma


I would like to ask.

I have a textEdit that accepts all values from xtragridview selected column. My problem is it ends with comma.

Currently have this output:

textEdit: Name1, Name2, Name3, Name4,

Expected output goes like this:

textEdit: Name1, Name2, Name3, Name4

I used this code:

For i = 0 To GridView1.RowCount - 1
   textEdit1.Text += GridView1.Columns.View.GetRowCellValue(i, "Names") + (", ")
Next

I need help that who can modified my code. I will be thankful. ^_^


Solution

  • Using list of string and join :

    DIM s AS NEW LIST (of string)
    For i = 0 To GridView1.RowCount - 1
       s.add( GridView1.Columns.View.GetRowCellValue(i, "Names") )
    Next
    textEdit1.Text = JOIN(s.toarray , ",")