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

Spacing Between Rows in Print Preview

6 Answers 288 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Khalid
Top achievements
Rank 1
Khalid asked on 09 Oct 2015, 03:03 PM
Is there a way to decrease row spacing between the rows in Print Preview?

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 12 Oct 2015, 02:53 PM
Hi Khalid,

Thank you for writing.

When RadGridView is about to be printed it sets row heights of the printed document according to the currently used height in the control. In order to accomplish your task you have a couple of options:
  1. Modify the row heights before printing the grid: GridViewRowInfo
  2. Use a GridPrintStyle and define a font, this class will also let you modify a number of other settings as well: GridPrintStyle
  3. Handle the PrintCellFormatting event and access each cell: PrintCellFormatting 
I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
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
Khalid
Top achievements
Rank 1
answered on 18 Oct 2015, 06:52 PM
Im not able to change the height for the summary row.
0
Khalid
Top achievements
Rank 1
answered on 18 Oct 2015, 06:59 PM
the summary row is not effected in the print preview.
0
Hristo
Telerik team
answered on 21 Oct 2015, 01:19 PM
Hi Khalid,

Thank you for writing back.

You can modify the row heights individually, including the height of the GridViewSummaryRowElement, which is affected by the value of the TableElement.RowHeight property: 
this.radGridView1.TableElement.RowHeight = 40;
foreach (GridViewRowInfo row in this.radGridView1.Rows)
{
    row.Height = 20;
}

I am also sending you a gif file showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
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
jamsheer
Top achievements
Rank 1
Veteran
answered on 03 Sep 2019, 07:14 AM

Hi,

    I used the above code for change the height for the summary row but, I am not able to change.

Please attach if you have any sample project, or correct way.

My code is here 

this.DgvLedger.TableElement.RowHeight = 15;
foreach (GridViewDataRowInfo row in DgvLedger.Rows)
{
row.Height = 15;
}

And I have one more issue in print or preview that is,

The summary row text alignment is different than the data rows.

In a grid data rows and summary rows has right alignment but, when print or preview data row alignment is same as in grid but summary rows alignment from right to middle automatically.

Please refer the attached pic for more

 

0
Dimitar
Telerik team
answered on 05 Sep 2019, 11:49 AM

Hi Jamsheer,

I have tested this and the row sizing works on my side (see attached). I would suggest opening a support ticket and attaching your project. This way we will be able to properly investigate this. 

To set the alignment you can use the ViewCellFormatting and PrintCellFormatting events. Here is an example:

private void RadGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
    if (e.Row is GridViewSummaryRowInfo)
    {
        e.PrintCell.TextAlignment = ContentAlignment.MiddleRight;
    }
    
}

private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridSummaryCellElement)
    {
        e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local);
    }
}

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Khalid
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Khalid
Top achievements
Rank 1
jamsheer
Top achievements
Rank 1
Veteran
Dimitar
Telerik team
Share this question
or