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

An array and a datagrid

P: n/a
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar
Nov 21 '05 #2

P: n/a
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #3

P: n/a
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than using
the split as you said and than into the arraylist would not be a problem as
well..

However than to use it in a datagrid will be iimpossible I think or with a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discussions.microsoft.com>
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #4

P: n/a
Hi,

You can only bind to a one dimensional array

Ken
--------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #5

P: n/a
thank you. this helps.

"rodchar" wrote:
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #6

P: n/a
Cor,

how exactly do I get the csv field into an arraylist?
I've tried
arrlist=ctype(arr,arrlist) dosen't work
"Cor Ligthert" wrote:
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than using
the split as you said and than into the arraylist would not be a problem as
well..

However than to use it in a datagrid will be iimpossible I think or with a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discussions.microsoft.com>
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar


Nov 21 '05 #7

P: n/a
rodchar,

You can add everything to an arraylist with
myarraylist.add(whatever)

I hope this helps?

Cor

"rodchar" <ro*****@discussions.microsoft.com>
Cor,

how exactly do I get the csv field into an arraylist?
I've tried
arrlist=ctype(arr,arrlist) dosen't work
"Cor Ligthert" wrote:
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than
using
the split as you said and than into the arraylist would not be a problem
as
well..

However than to use it in a datagrid will be iimpossible I think or with
a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended
Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discussions.microsoft.com>
> Ken,
>
> Is there a way to get a comma-delimited field into an array list. I
> know I
> can do it with split function but that only works with arrays.
>
> rodchar
>
> "Ken Tucker [MVP]" wrote:
>
>> Hi,
>>
>> Here is an example that uses an arraylist.
>> http://www.onteorasoftware.com/Downl...todatagrid.zip
>>
>> Ken
>> ------------------
>> "rodchar" <ro*****@discussions.microsoft.com> wrote in message
>> news:13**********************************@microsof t.com...
>> Hey all,
>>
>> what's the best way to get the contents of an array into a datagrid,
>> edit
>> the values, and then save edited values back into array format?
>>
>> thanks,
>> rodchar
>>
>>
>>


Nov 21 '05 #8

P: n/a
Set the DataGrid's datasource property to the array/arraylist object.

Assign the DataGrid.Item(index) to the array/arraylist object.

Check out my article, "DataSet, DataGrid and the Treeview controls" at
developersdex.com.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #9

P: n/a
when I bind my array to the datagrid, all I get is the length column, how do
I get the actual values to show up?
"Ravichandran J.V." wrote:
Set the DataGrid's datasource property to the array/arraylist object.

Assign the DataGrid.Item(index) to the array/arraylist object.

Check out my article, "DataSet, DataGrid and the Treeview controls" at
developersdex.com.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.