Bind array to a datagrid

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
 
C

Chris, Master of All Things Insignificant

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
 
M

Microsoft

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!
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top