Results 1 to 3 of 3

Thread: [RESOLVED] String List from DataGridView

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [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.
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    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...
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: String List from DataGridView

    Thank alot for your big help.
    Works very fine...
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width