I have a WPF 4.0 DataGrid that is bound to a DataTable using AutoGenerateColumns=True. The columns are dynamic, however I know there is always going to be a column named ID and I would like to hide this column. Is there a way I can do this?
in your datagrid, subscribe for the AutoGeneratingColumn
event, the event args
(DataGridAutoGeneratingColumnEventArgs
) has the column name and a "Cancel
", if the column name is ID then set Cancel = true
. should do the trick.