BobNoobGuy BobNoobGuy - 1 month ago 12 Question

Writeline to textbox?

Stupid question here, but here is my code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dt As DataTable
dt = CType(dgrGrid.DataSource, DataTable).Copy
Dim drs() As DataRow = dt.Select("CustomerID = 222")
For Each row As DataRow In drs
For Each item As Object In row.ItemArray
Debug.WriteLine("{0}", item)
End Sub

I can see in the debug window all my values.

Now if I need to spit out this value to a textbox, I am not sure how to do it.

The goal is to keep using
to get the value.


You can use something like this:

Dim rows = dt.Select() ' Or select using a criteria like you did
Me.TextBox1.Text = String.Join(Environment.NewLine, _
    rows.Select(Function(r) String.Join(",", r.ItemArray)))

The TextBox1 should be MultiLine to show Environment.NewLine.

Also if you are looking for something like AppendLine, use:

Me.TextBox1.AppendText("something" & Environment.NewLine)