How to: Provide Custom Print Cell Appearance

  • 5 min to read

This example shows how to create custom PrintCellStyle for grid columns to bring a custom printing appearance for PopupImageEdit, CheckBoxEdit and MemoEdit.

To learn more on how to implement similar functionality in Silverlight, refer to the T245823 example.

<Window x:Class="GridExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:local="clr-namespace:GridExample" 
        Width="600" Height="350"
        >

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GridExample;component/Themes/PrintCellStylesWPF.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>        
    </Window.Resources>

    <Grid VerticalAlignment="Top">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <dxg:GridControl Name="grid" AutoGenerateColumns="AddNew">
            <dxg:GridControl.Columns>

                <dxg:GridColumn FieldName="PlainText"/>

                <dxg:GridColumn FieldName="MemoText" 
                                PrintCellStyle="{StaticResource MemoColumnPrintingStyle}"
                                >
                    <dxg:GridColumn.EditSettings>
                        <dxe:MemoEditSettings/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>

                <dxg:GridColumn FieldName="BooleanMember"
                                PrintCellStyle="{StaticResource CheckEditColumnPrintingStyle}"
                                > 
                    <dxg:GridColumn.EditSettings>
                        <dxe:CheckEditSettings/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>

                <dxg:GridColumn FieldName="Image"
                                PrintCellStyle="{StaticResource ImageColumnPrintingStyle}"
                                >
                    <dxg:GridColumn.EditSettings>
                        <dxe:PopupImageEditSettings/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>

            </dxg:GridControl.Columns>

            <dxg:GridControl.View>
                <dxg:TableView Name="view"/>
            </dxg:GridControl.View>         
        </dxg:GridControl>

        <Button Grid.Row="1" Width="150" Name="PrintButton" Click="PrintButton_Click" Content="Show print preview"/>
    </Grid>
</Window>