Spacing Between Rows in Print Preview

7 posts, 0 answers
  1. Khalid
    Khalid avatar
    11 posts
    Member since:
    Sep 2010

    Posted 09 Oct 2015 Link to this post

    Is there a way to decrease row spacing between the rows in Print Preview?
  2. Hristo
    Admin
    Hristo avatar
    1517 posts

    Posted 12 Oct 2015 Link to this post

    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
  3. Khalid
    Khalid avatar
    11 posts
    Member since:
    Sep 2010

    Posted 18 Oct 2015 in reply to Hristo Link to this post

    Im not able to change the height for the summary row.
  4. Khalid
    Khalid avatar
    11 posts
    Member since:
    Sep 2010

    Posted 18 Oct 2015 in reply to Khalid Link to this post

    the summary row is not effected in the print preview.
  5. Hristo
    Admin
    Hristo avatar
    1517 posts

    Posted 21 Oct 2015 Link to this post

    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
  6. jamsheer
    jamsheer avatar
    64 posts
    Member since:
    Feb 2017

    Posted 03 Sep 2019 Link to this post

    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

     

  7. Dimitar
    Admin
    Dimitar avatar
    2881 posts

    Posted 05 Sep 2019 Link to this post

    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.
Back to Top