How to remove extra column Datagrid

Viewed 35271

i have binded itemsource to Datatable for Datagrid . it shows extra columns how to remove it

My code :

<DataGrid Name="dataGrid"  IsReadOnly="True"  VerticalAlignment="Top"
          ItemsSource="{Binding Cus}" AutoGenerateColumns="True"/>

it show extra columns How to remove it ?

Screen shot : enter image description here

7 Answers

Add the attribute ColumnWidth="*" in the DataGrid object.

<Grid>
    <DataGrid x:Name="datagridname" Margin="10" ItemsSource="{Binding}" IsReadOnly="True" ColumnWidth="*"/>
</Grid>
Related