Class objects as Datasources [modified]
-
I have a "List<CSomeObject> someList" with several properties. When I assign my "dataGridView.DataSource = someList" it populates the DataGridView, but the order of the properties is seemingly random. Can I specify the order somehow? Also, can I change the name of the columns instead of being forced to use the Property name? -- modified at 15:45 Monday 12th June, 2006
-
I have a "List<CSomeObject> someList" with several properties. When I assign my "dataGridView.DataSource = someList" it populates the DataGridView, but the order of the properties is seemingly random. Can I specify the order somehow? Also, can I change the name of the columns instead of being forced to use the Property name? -- modified at 15:45 Monday 12th June, 2006
You can create your own columns for the DataGridView by setting its
AutoGenerateColumns
property to false and then adding DataGridViewColumn-derived (e.g.DataGridViewTextBoxColumn
) columns to it with your desiredHeaderText
andDataPropertyName
properties, in the order you want, preferably prior to data binding. -- I've killed again, haven't I?