I tried the sample, It is working fine for me.
private void Form1_Load(object sender, EventArgs e)
{
ObservableCollection<Car> cars = new ObservableCollection<Car>();
cars.Add(new Car("Ford", "Mustang", 1967));
cars.Add(new Car("Shelby AC", "Cobra", 1965));
cars.Add(new Car("Chevrolet", "Corvette Sting Ray", 1965));
loadGridview(cars);
}
private void loadGridview(ObservableCollection<Car> list)
{
dgGrid.DataSource = list;
}
public class Car
{
private string _make;
private string _model;
private int _year;
public Car(string make, string model, int year)
{
_make = make;
_model = model;
_year = year;
}
public string Make
{
get { return _make; }
set { _make = value; }
}
public string Model
{
get { return _model; }
set { _model = value; }
}
public int Year
{
get { return _year; }
set { _year = value; }
}
}
I placed the entire code for you. Try it once.