0
votes

DataGrid columns are type locked. If you try and input a string into a column which is expecting an Int, you get the following error message.

Input string was not in a correct format.Couldn't store 'example string' in ItemNo Column. Expected type is Int32.

The goal behind this is to be able to upload data from a CSV in any format, and have the datagrid accept it. The itemsource is bound to a source DataTable to ensure that the right amount of columns are autogenerated, as well as to get the columnnames to populate the ComboBox header

enter image description here

Does anyone know a way to allow for flexible input inside of a dataGrid?

1
Didn't I suggest either a DataTable or ObservableCollection<ExpandoObject>? I think you were the guy. Make all the columns or properties strings, and you're good. In setting up CSV import, column value type validation could be a discreet step.15ee8f99-57ff-4f92-890c-b56153
besides using object as type?Francesco B.

1 Answers

1
votes

Usually being type safe and some validation is considered a good thing.

Bind itemssource to a collection of some type that has all it's public properties of type string. Then you can type what you want in each of them.