This is a migrated thread and some comments may be shown as answers.

PrintPreview Print Settings

4 Answers 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose antonio
Top achievements
Rank 1
Jose antonio asked on 05 Jul 2014, 05:11 PM
How I can change the values ​​of the Style Settings section programmatically?

4 Answers, 1 is accepted

Sort by
0
Accepted
Ralitsa
Telerik team
answered on 09 Jul 2014, 07:47 AM
Hi Jose Antonio,

Thank you for contacting us. 

You need to set the CellBackColorCellFont, CellPadding, etc. properties of GridPrintStyle. Please take a look at the following code sample: 
private void radButton1_Click(object sender, EventArgs e)
        {
            GridPrintStyle style = new GridPrintStyle();
            style.FitWidthMode = PrintFitWidthMode.FitPageWidth;
            style.PrintAllPages = true;
            style.PrintGrouping = true;
            style.PrintHeaderOnEachPage = true;
            style.PrintSummaries = true;
 
            style.CellBackColor = Color.Aquamarine;
            style.CellFont = new Font("Arial", 13, FontStyle.Regular);
            style.CellPadding = new Padding(0, 0, 10, 0);
             
            style.GroupRowBackColor = Color.HotPink;
            style.GroupRowFont = new Font("Arial", 13, FontStyle.Italic);
             
            style.HeaderCellBackColor = Color.GreenYellow;
            style.HeaderCellFont = new Font("Arial", 12, FontStyle.Bold);
 
            style.SummaryCellBackColor = Color.DarkSeaGreen;
            style.SummaryCellFont = new Font("Arial", 12, FontStyle.Bold);
 
            this.radGridView1.PrintStyle = style;
            this.radGridView1.PrintPreview();
        }

Please refer to our help articles GridPrintStyle and Events and Customization which demonstrate how you can customize print style of RadGridView.

I've also attached a sample demo application. 

Should you have further questions, I would be glad to help. 

Regards,
Ralitsa
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Aref
Top achievements
Rank 1
answered on 24 Dec 2015, 10:59 AM

Hi 
Is it possible to access print setting form via code ? I want to modify some items on that form like it's font and right to left option but I do not know how to do that. I am looking forward to hearing from you.

0
Stefan
Telerik team
answered on 25 Dec 2015, 07:35 AM
Hello Aref,

To introduce modifications to the dialog itself, you have to inherit from GridViewPrintSettingsDialog and in the inheritor to introduce the desired modifications. Then, create a factory which implements the IPrintSettingsDialogFactory interface and pass your dialog instance in the CreateDialog method. Finally, set an instance of your factory to the PrintSettingsDialogFactory property of RadGridView. Here is a sample:
class MyPrintSettingsDiagloFactory : IPrintSettingsDialogFactory
{
    public Form CreateDialog(RadPrintDocument document)
    {
        return new MyGridViewPrintSettingsDialog(document);
    }
}
 
class MyGridViewPrintSettingsDialog : GridViewPrintSettingsDialog
{
    public MyGridViewPrintSettingsDialog(RadPrintDocument document)
        : base(document)
    {
    }
    protected override void LoadSettings()
    {
        base.LoadSettings();
 
        this.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
    }
}

radGridView1.PrintSettingsDialogFactory = new MyPrintSettingsDiagloFactory();

I hope that you find this information useful.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Aref
Top achievements
Rank 1
answered on 25 Dec 2015, 11:09 AM
Dear Stefan 
Thanks for your useful information. It helped a lot.
Sincerely yours
Aref
Tags
GridView
Asked by
Jose antonio
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Aref
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or