Owain Esau
Owain Esau

Reputation: 1922

WPF DataGrid boolean fields being displayed as true/false rather than checkbox

I am very new to C#, in fact i just started today and can't seem to get this working.

Basically i am pulling data from SQL Server and displaying it in a data grid. If i use AutoGenerateColumns the boolean fields come through as a checkbox which is what i want. With it off (which i want as i feel like it gives me more control over the sizing of each column), the field displays as True / False.

The XAML for the DataGridTextColumn looks like this:

<DataGridTextColumn Header="Ceased" Binding="{Binding Ceased}" Width="1*" >
    <DataGridTextColumn.ElementStyle>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Center" />
        </Style>
    </DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

It is the same for all columns. How can i get this to display as a checkbox in the Grid again?

Upvotes: 2

Views: 1250

Answers (1)

Erko
Erko

Reputation: 391

To get a column to display as checkboxes replace DataGridTextColumn with DataGridCheckBoxColumn

Upvotes: 3

Related Questions