Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

VS 2012 How To Get All Cell Values From One DataGridView Column?

$
0
0
I need to get all the cell values in a colum.

I have Tried the following code below, but it is only returning the value of the Last Row in the column.

So if my column were...

| COL 1 | |COL 2| |COL 3|.....
12345
12345
12345
2468

It would only return 2468 in a textbox


Code:

For Each dr As DataGridViewRow In dataGridView.Rows
        Dim col1 As String = dr.Cells("Col1").Value.ToString()
        Dim col2 As String = dr.Cells("Col2").Value.ToString()
        Dim col3 As String = dr.Cells("Col3").Value.ToString()
Next


Viewing all articles
Browse latest Browse all 27514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>