[RESOLVED] String List from DataGridView
I have a DataGridView and i want to build a string list from that...
I have tried many way wothout a good result.
I need to build this list of string and after that to make a single string to send it via e-mail
Code:
.....................
Dim produs_extras As List(Of String) = New List(Of String)
Dim nr_crt As Integer = 0
For Each produs_row As DataGridViewRow In Me.dgv_detalii_comanda.Rows
produs_extras.Add(produs_row.Cells.Item(nr_crt).Value)
nr_crt = nr_crt + 1
Next
For Each produs_perforat As String In produs_extras
sursa = lista_produse.Replace(sursa, produs_perforat)
Next
.......................
how can i solve that ?
Thanks in advice.
Re: String List from DataGridView
If you are going to build a single string then go for the StringBuilder Class..
This could be done like
Code:
Dim sb As New System.Text.StringBuilder
Dim nr_crt As Integer = 0
For Each produs_row As DataGridViewRow In Me.dgv_detalii_comanda.Rows
sb.AppendLine(produs_row.Cells.Item(nr_crt).Value)
' produs_extras.Add(produs_row.Cells.Item(nr_crt).Value)
nr_crt = nr_crt + 1
Next
' For Each produs_perforat As String In produs_extras
' sursa = lista_produse.Replace(sursa, produs_perforat)
' Next
And you can get the string using sb.ToString() Method...
Re: String List from DataGridView
Thank alot for your big help.
Works very fine... ;)