Re: how to bind arraylist to datagridview

Tech-Archive recommends: Fix windows errors by optimizing your registry



Amir,

Well, what is the exception you are getting?


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"weird0" <amirediwan@xxxxxxxxx> wrote in message news:1192564028.554622.295700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Purpose: The objective is to update or add a new row in datagridview
using an arraylist

I have an arraylist inside of a class and i added an object to the
arraylist on the button click event. Then, after clearing the
datagridview1, i re-assigned the arraylist to the datasource property.
But it does not work, since the application crashes. The code goes
something like this:

Node n1=new Node();
State st1=new State("State",1);
n1.statesList.Add(s1);
datagridview1.DataBindings.Clear();
datagridview1.Refresh();
datagridview1.Datasource=n1.stateList; // Damn!!!! it crashes ..

Need help
Amir Diwan


.


Quantcast