A set of .NET Framework managed libraries for developing graphical user interfaces.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can I retrieve all the values from a row in a DGV into an array?
If you are using the data binding, then get the values from the source object.
Or try this:
Dim values As Object() = DataGridView1.Rows(0).Cells.Cast(Of DataGridViewCell).Select(Function(c) c.Value).ToArray
This example gets the first row. Use another index or adjust it for your needs.
How would I do the same thing for column values. I've tried altering the code but can not solve it.
I found some code and edited to the follow, however your code for the rows in neater.
In case of columns, for example:
Thank you again Viorel for your help that fixed it for me.
What am i missingViorel?
What am I missing in the second button click event. The first one give me a antedated string but the second wont produce the array I would like to have?
Sign in to comment
0 additional answers
Sort by: Most helpful