By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

Bind array to a datagrid

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
"Microsoft" <ma*@mas.com> wrote in message
news:O3*************@TK2MSFTNGP14.phx.gbl...
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



Nov 21 '05 #2

P: n/a
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!
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:et**************@TK2MSFTNGP11.phx.gbl...
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
"Microsoft" <ma*@mas.com> wrote in message
news:O3*************@TK2MSFTNGP14.phx.gbl...
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




Nov 21 '05 #3

P: n/a
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

"Microsoft" <ma*@mas.com>
..
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!
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:et**************@TK2MSFTNGP11.phx.gbl...
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
"Microsoft" <ma*@mas.com> wrote in message
news:O3*************@TK2MSFTNGP14.phx.gbl...
>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
>
>
>
>
>
>
>
>



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.