I have a DataGridView and I need to add custom objects to it. Consider the following code:
DataGridView grid = new DataGridView();
grid.DataSource = objects
You can use databindings with AutoGenerateColumns = false
and using DataPropertyName like this
grid.Columns["Column_name_1"].DataPropertyName = "public_property_1";
grid.Columns["Column_name_2"].DataPropertyName = "public_property_2";
This way only bound columns will be shown in the datagridview, and you can create the columns in the editor if you want. Public properties can be any public attribute within your object.
If you are editing your data from the datagridview, then you should use NotifyPropertyChanged in the set methods. Se my question/answer here where I explain this all the way down.