Destabilizator Destabilizator - 2 years ago 112 Question

VB.NET Get everything from DataGridView

Is there a method to get all non-empty data currently in DataGridView, other than iterating through row/columns indexes? "Get" as in pump it all in array/vector or most conveniently matrix.
I'd like to do this as quickly as possible and don't care about the order of items, would Parallel.ForEach be enough?

Answer Source

I have figured it out, the magic is in Casting :) (DataGridView is name of my object, not the type)

Parallel.ForEach(DataGridView.Rows.Cast(Of DataGridViewRow), _
            Parallel.ForEach(currentRow.Cells.Cast(Of DataGridViewCell), _
                       // do stuff
                   End Sub)
        End Sub)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download