Bind array to a datagrid

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

I am able to set the datasource of a datagrid as a simple array, but on the
form it only displays the length of the strings in the array. Not the
actual items in the string.
Dim lastpatch As String()

for loop that adds text to the array

lastpatch(i) = result40

end loop

datagrid1.datasource = laspatch
 
I've never tried to bind an array to a datagrid, I'm not saying it can't be
done, but this is how I've always done what you are trying to do.

\\\
Sub CodeNotTested
Dim T as new DataTable
Dim R as DataRow
T.Columns.Add("MyString")

for loop that adds text to the array
R = T.NewRow
R(0) = result40
T.Rows.Add(R)
next
datagrid1.datasource = T

Chris
 
I found similiar code in google and changed my code. Yours helped my put
the finishing touches.. Now I am trying to figure out how to change the
width of the rows.. Thank you!
 
Hi,

I am curious why you take this hard way to go (you are not the first) and
not use direct a datatable as your datasource?

Cor
 
Back
Top