An array and a datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Hi,

You can only bind to a one dimensional array

Ken
--------------------
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
 
Cor,

how exactly do I get the csv field into an arraylist?
I've tried
arrlist=ctype(arr,arrlist) dosen't work
 
rodchar,

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

I hope this helps?

Cor
 
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
 
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?
 

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

Similar Threads

database records into an array 2
array in dataset 4
2 arrays into 1 2
Binding DataGrid to an Array 4
arrays of integers 5
Array question 3
Simple Array Question 1
residual of some sort 1

Back
Top