Binding DataGrid To IList

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 null and then re bind it to the ArrayList! Isnt there a
"pretier" way?
Thanks ahead

--Rami
 
D

DalePres

If you look up the DataGrid.DataSource property in the MSDN Library you will
find some of the requirements for using an ArrayList as the DataSource for a
DataGrid.

You don't say what type your ArrayList items are so it is difficult to say
why they might not be displaying as expected. Also, is this a web
application or a Windows.Forms application?

DalePres
MCAD, MCDBA, MCSE
 
R

Rami

First, Thanks for your reply!
Second my ArrayList items are of simpe string objects...
Third - My application is a Windows.Forms...
And last - you didnt say anything about the second part which is more
troubling - is there a way to refresh the DataGrid?
Thanks again

--Rami
 
D

DalePres

To answer your first question, one way is to create a class and wrap your
string in it as a property. This would give a name to your string and the
DataGrid would use the property name as the column name and the string as
the value.

To answer your second question. I could be wrong but I don't think there's
an easier way.

DalePres
MCAD, MCDBA, MCSE
 

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