Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Datagrid is bound to DataTable. But my Datagrid shows an extra empty column at the end. What is the solution to remove that extra column.
Posted
Comments
rudrik8 2-Jun-11 7:19am    
check that if u have add column from the design.
rc89994 2-Jun-11 7:38am    
no. i did not add column in design view.
Wayne Gaylard 2-Jun-11 8:49am    
Post your code where you fill the datatable, then someone might help you

1 solution

Set DataGrid's AutoGenerateColumns property to false. Hope this helps.

<pre lang="xml"><my:DataGrid  AutoGenerateColumns="False" Margin="36,23,45,112" Name="dataGrid1" Grid.Row="1" Background="White" VerticalGridLinesBrush="DarkGray" VerticalScrollBarVisibility="Hidden" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"  >
            <my:DataGrid.Columns>
                <my:DataGridTemplateColumn Header="Icon" Width="50" IsReadOnly="True" >
                    <my:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Path=ImgPath}" Width="20" Height="20"/>
                        </DataTemplate>
                    </my:DataGridTemplateColumn.CellTemplate>
                </my:DataGridTemplateColumn>
                <my:DataGridTextColumn Header="Position"  Binding="{Binding Path=PO}"   />
                <my:DataGridTextColumn Header=" Name" Binding="{Binding Path=NA}"  />
                <my:DataGridTextColumn Header="Gender" Binding="{Binding Path=GE}"  />
                <my:DataGridTextColumn Header="Status" Binding="{Binding Path=ST}"  />
                <my:DataGridTextColumn Header="Machine" Binding="{Binding Path=MA}"  />
            </my:DataGrid.Columns>
        </my:DataGrid>


 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900