Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What error message do you get when you set your 2 dimensional array as your datagridview's data source? Well, you can loop and assign the values to your datagridview if the data source command is giving you an error.</p> <pre><code>'Ensure that the required number of rows are available If DataGridView.Rows.Count &lt; some2darray.GetUpperBound(0) Then DataGridView.Rows.Add((some2darray.GetUpperBound(0) + 1) - DataGridView.Rows.Count) End If 'Also ensure that the required number of columns are available 'Fill up the datagridview with the data from the 2D array For x = 0 to some2darray.GetUpperBound(0) For y = 0 to some2darray.GetUpperBound(1) DataGridView.Item(y, x).Value = some2darray(x, y) Next Next </code></pre> <p>If your 2Darray does not have the point of the reference in it and it has to obtain its values from some other source then use this code <code>ReDim Preserve some2darray(x, y)</code> e.g.</p> <pre><code>For x = 0 to rowcountofthesource For y = 0 to columncountofthesource ReDim Preserve some2darray(x, y) 'Code here DataGridView.Item(y, x).Value = some2darray(x, y) Next Next </code></pre> <p>If your 2Darray is taking all of its data from another source in one go. Then ReDim Preserve your 2Darray to the total rows and columns of that source e.g. <code>ReDim Preserve some2darray(totalrowsofthesourcehere, totalcolumnsofthesourcehere)</code> and type it outside the loop as you don't need to do it again and again. If your array is empty before use and contains no data then you don't need to use <code>ReDim Preserve</code> , just use <code>ReDim some2darray(int, int)</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload