We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SFDataGrid PrintPreview Orientation

Hello Sir,

 

In SfDataGrid PrintPreview Window,the default page orientation is portrait.

I would like to change it from code behind.Means Once when the preview window opened then i selected orientation as landscape and i closed it.Again i opened preview window,but the orientation changed to portrait.How can i make it as landscape.

 

Thanks & Regards

Venkat.


7 Replies

ES Elangovan S Syncfusion Team October 9, 2015 06:51 AM UTC

Hi Venkat,

Thank you for contacting Syncfusion Support.

We have analyzed your query, by default the SfDataGrid print preview is set as portrait. You can also modify the print preview page orientation in code behind, please find the following code example.

Code Example [C#]:


dataGrid.PrintSettings.PrintPageOrientation = PrintOrientation.Landscape;



You can download the sample from the following location:

http://www.syncfusion.com/downloads/support/forum/120718/ze/PrintingDemo1520448467

Please let us know if you have any query.

Regards,

Elangovan S



VR Venkata Rao October 10, 2015 06:46 AM UTC

Hi Elangovan ,
I executed your sample and,has some errors.
i.e,dataGrid.PrintSettings.PrintPageOrientation = PrintOrientation.Landscape;
is replaced with dataGrid.PrintSettings.PrintManagerBase.PrintPageOrientation = PrintOrientation.Landscape;
But PrintManagerBase is returning null value and i created CustomGridPrintManager derives from GridPrintManager
and done like this.
 dataGrid.PrintSettings.PrintManagerBase= CustomGridPrintManager(dataGrid);

But still the orientation is portrait.


ES Elangovan S Syncfusion Team October 12, 2015 01:13 PM UTC

Hi Venkat,

We have analyzed your query, it is not possible to set the PrintPageOrientation property value directly from the PrintManagerBase. We need to override the InitializeProperties method from the GridPrintManager and from that only you can set the PrintPageOrientation with in that. Please refer the following code example.


internal class CustomPrintManager : GridPrintManager

    {

        public CustomPrintManager(SfDataGrid grid)

            : base(grid)

        {

        }


        protected override void InitializeProperties()

        {

            base.InitializeProperties();

            this.PrintPageOrientation = PrintOrientation.Landscape;

        }

    }



You can also download the sample from the following location:

http://www.syncfusion.com/downloads/support/forum/120718/ze/SfDataGrid1524788208

Note: In the 13.2 version only we have introduced the sfdataGrid.PrintSettings.PrintPageOrientation property, so could you please update your version you have using. It will help us to analyze more on this.

Please let us know if you have any query.

Regards,

Elangovan S



VR Venkata Rao replied to Elangovan S October 15, 2015 05:30 AM UTC

Hi Venkat,

We have analyzed your query, it is not possible to set the PrintPageOrientation property value directly from the PrintManagerBase. We need to override the InitializeProperties method from the GridPrintManager and from that only you can set the PrintPageOrientation with in that. Please refer the following code example.


internal class CustomPrintManager : GridPrintManager

    {

        public CustomPrintManager(SfDataGrid grid)

            : base(grid)

        {

        }


        protected override void InitializeProperties()

        {

            base.InitializeProperties();

            this.PrintPageOrientation = PrintOrientation.Landscape;

        }

    }



You can also download the sample from the following location:

http://www.syncfusion.com/downloads/support/forum/120718/ze/SfDataGrid1524788208

Note: In the 13.2 version only we have introduced the sfdataGrid.PrintSettings.PrintPageOrientation property, so could you please update your version you have using. It will help us to analyze more on this.

Please let us know if you have any query.

Regards,

Elangovan S


Hi,

How can i get SfDataGrid that can be converted into PrintDocument.So that i can assign that printdocument to printpreview control.

Thanks & Regards,

Venkat



ES Elangovan S Syncfusion Team October 16, 2015 07:01 AM UTC

Hi Venkat,

We have analyzed your query, as per your requirement you can refer our Custom Printing sample which is available in our Dashboard samples or you can download the sample from the following location.

Sample Link:

http://www.syncfusion.com/downloads/support/forum/120718/ze/CustomPrintingDemo-2017024061

Could you update the version detail which you are using, it will help us to give appropriate solution for your query.

Regards,

Elangovan S



VR Venkata Rao October 28, 2015 12:03 PM UTC

            
hi             

In the given example http://www.syncfusion.com/downloads/support/forum/120718/ze/CustomPrintingDemo-2017024061 how to initialize the zoomFactor value.What is this ZoomFactor.
I would like to give border to my printpage,but here there is no option.Please can you solve these things.

Thanks and Regards
Venkat


JG Jai Ganesh S Syncfusion Team October 30, 2015 01:00 PM UTC

Hi Venkat,

Thank you for the update.

We have analyzed your queries and please find the response for your queries below,

Query 1: (How to initialize the zoomFactor value.What is this ZoomFactor)

ZoomFactor value is used to adjust the zooming level for print page and it binded to ZoomSlider. It was directly binded from the source and we cannot initialize the the zoomFactor value.

Query 2: (I would like to give border to my printpage,but here there is no option.Please can you solve these things.)

You can give a border for print page by writing the style for PrintPageControl and set the border like below code example,

Code Example:

<Style TargetType="syncfusion:PrintPageControl">

                <Setter Property="Background" Value="White" />

                <Setter Property="BorderBrush" Value="Gray" />

                <Setter Property="BorderThickness" Value="1" />

                <Setter Property="Template">

                    <Setter.Value>

                        <ControlTemplate TargetType="syncfusion:PrintPageControl">

                            <Viewbox x:Name="PART_Viewbox">

                                <Border Width="{Binding PrintPageWidth}"

                                Height="{Binding PrintPageHeight}"

                                Background="{TemplateBinding Background}"

                                BorderBrush="{TemplateBinding BorderBrush}"

                                BorderThickness="{TemplateBinding BorderThickness}"

                                SnapsToDevicePixels="True">

                                    <Border Margin="30"  BorderThickness="4" BorderBrush="Blue" >

                                    <Border Margin="{Binding PrintPageMargin}">

                                       

                                        <Grid >

                                            <Grid.RowDefinitions>

                                                <RowDefinition Height="Auto" />

                                                <RowDefinition Height="*" />

                                                <RowDefinition Height="Auto" />

                                            </Grid.RowDefinitions>

                                            <ContentControl x:Name="Part_PageHeader"

                                                    Height="{Binding PrintPageHeaderHeight}"

                                                    ContentTemplate="{Binding PrintPageHeaderTemplate}" />

                                            <Border x:Name="PartScalingBorder" Grid.Row="1">

                                                <ContentPresenter x:Name="Part_Panel" />

                                            </Border>

                                            <ContentControl x:Name="Part_PageFooter"

                                                    Grid.Row="2"

                                                    Height="{Binding PrintPageFooterHeight}"

                                                    ContentTemplate="{Binding PrintPageFooterTemplate}" />

                                        </Grid>

                                    </Border>

                                    </Border>

                                </Border>

                            </Viewbox>

                        </ControlTemplate>

                    </Setter.Value>

                </Setter>
            </Style>



We have also modified the sample based on this and you can download the sample from the below location,

Sample:

http://www.syncfusion.com/downloads/support/directtrac/146225/ze/CustomPrintingDemo1777066341

Regards,
Jai Ganesh S

Loader.
Live Chat Icon For mobile
Up arrow icon