2,892 questions
Hi
Here is one way to do it. A stand alone example.
Option Strict On
Option Explicit On
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' add some test data
With DataGridView1
.Rows.Add(Nothing, "Apple")
.Rows.Add(Nothing, "Orange")
.Rows.Add(Nothing, "Pineapple")
.Rows.Add(Nothing, "Grapes")
.Rows.Add(Nothing, "Litchi")
End With
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Clear()
Dim comma As String = ","
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If Not i = DataGridView1.NewRowIndex Then
Dim s As String = DataGridView1("Column2", i).Value.ToString
If i < DataGridView1.NewRowIndex - 1 Then
TextBox1.Text &= s & ","c & vbCrLf
Else
TextBox1.Text &= s
End If
End If
Next
End Sub
End Class