Binding DataGrid To ArrayList

R

Rami

Hey,
I Tried to bind a DataGrid to an ArrayList, and had 2 problems:
1. The DataGrid shows the Length property of the items instead of their
text - how can I change that?
2. After binding, I add new elements to the ArrayList but the DataGrid
doesnt refresh's it's view - I have to set the DataSource property of
the DataGrid to Nothing and then re bind it to the ArrayList! Isnt
there a "pretier" way?
Thanks ahead

--Rami
 
K

Ken Tucker [MVP]

Hi,

When you bind to an arraylist it will show the properties of the
class in the arraylist in the datagrid. It will not show public variables.
Here is an example.

www.onteorasoftware.com/downloads/arraylisttodatagrid.zip

Ken
---------------------
Hey,
I Tried to bind a DataGrid to an ArrayList, and had 2 problems:
1. The DataGrid shows the Length property of the items instead of their
text - how can I change that?
2. After binding, I add new elements to the ArrayList but the DataGrid
doesnt refresh's it's view - I have to set the DataSource property of
the DataGrid to Nothing and then re bind it to the ArrayList! Isnt
there a "pretier" way?
Thanks ahead

--Rami
 
G

Guest

I've been developing a user control called MultiGrid which is editable that
binds to Arraylists, arrays, datatables, DataSets, and DataViews. It is not
an upgraded DataGrid but written from scratch. It binds to arrays and
Arraylists of classes (including public properties and public variables) as
well as Structures. Unfortunately, when you updata an arraylist or array in
code, you have to call an update method to reflect the changes in the gird.

You can edit the gird cells and they will reflect changes in the datasource.
However, It does change values in datatables, etc. but does not update the
unerlying DataBase. The user has to do this by code.

I don't have the documentation done yet but would be glad to send you the
assembly.dll and an example of how to use it. The various properties and
Methods are available in the Intelligentsense. I'd be happy to have someone
give it a try and let me know what they think. My e-mail is
(e-mail address removed). E-mail me if you're interested.
 
R

Rami

Thanks for your reply - it really helped me!
But what about my second question - after dding new elements to the
ArrayList,
The DataGrid isnt refreshing automatically, is there a way to refresh
it's view so that it wills show the new items?
I Tried the Refresh and ResumeLayout Methods with no luck...
Thanks again,

--Rami
 
K

Ken Tucker [MVP]

Hi,

Set the datagrids datasource to the arraylist to get it to
refresh.

Ken
------------------
Thanks for your reply - it really helped me!
But what about my second question - after dding new elements to the
ArrayList,
The DataGrid isnt refreshing automatically, is there a way to refresh
it's view so that it wills show the new items?
I Tried the Refresh and ResumeLayout Methods with no luck...
Thanks again,

--Rami
 
R

Rami

But wouldnt that restart the hole binding process all over again?
Isnt there a way to make the DataGrid refresh only the newly added
listItems or only the updated items?
Thanks again,

--Rami
 

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