Kottan
Kottan

Reputation: 5076

Windows Forms: DataGridView Binding Question

I have a Winform DataGridView, which has a number of predefined columns. Now I have an array of objects (the object structure conforms to the defined gridview columns) and I want to bind the gridview to this array (with gridview.datasource = array)

The problem is now, that I get several new columns in the grid after the predefined columns (the predefinded columns remain empty). How can I achive, that the array data is loaded into the predefined columns?

Upvotes: 1

Views: 367

Answers (1)

SLaks
SLaks

Reputation: 888213

You need to set the DataPropertyNames of the existing columns to match the properties of the objects in the array.

Upvotes: 2

Related Questions