Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing an array using a DataGrid

Status
Not open for further replies.

warlow

Technical User
Feb 18, 2004
7
GB
I would like to edit/read/write the contents of an array using a DataGrid.

I have started with Form1 to which I have visually:

Added DataGrid1
Added DataSet1
Added Table1 and Column1 to DataSet1
Chosen DataTable1 as the DataSource for DataGrid1

I can run this program now and I get a nice grid where I can add, edit, delete, copy and even sort the text I enter - wonderful, just what I wanted.

So now what's the easiest/best/recommended way to tie this to an array so that the contents also get updated? So far I've only found DataGrid examples using Access/SQL/database stuff which I hope I can do without.
 
It appeared that I should be able to use the SetDataBinding method of the DataGrid to bind an array to a column.

So adding to the visually created stuff above I added a button to form1 with the following code in it's click event routine:

Dim myArray() as String = {"I", "am", "not", "sure"}
DataGrid1.SetDataBinding(myArray , "" ) '????

This nearly works except that when I run it and click the button, the table column picks up the Length of each element so I get rows with 1, 2, 3, 4, instead of the strings.

According to the DataGrid Class description, a single dimension array is a valid datasource for the SetDataBinding method of a DataGrid but what should the syntax be?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top