Problems in printing grid with multiline field

2 posts, 0 answers
  1. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 17 Jan 2014 Link to this post

    I have a gridView in a winform. I have set one of the column "Note" to:
    wraptext= true
    multiline= true

    This is my print button:
    private void BtnPrint(object sender, EventArgs e)
            {
                GridPrintStyle style = new GridPrintStyle();
                style.FitWidthMode = PrintFitWidthMode.FitPageWidth;     
                style.PrintHeaderOnEachPage = true;
                this.radGridView1.PrintStyle = style;
                this.radGridView1.PrintPreview();       
            }
    despite the above, the result I get, see picture attached, is not the expected one.The multilines field doesn't shows properly the content. Part of the text is out of the visible box.
    I have tried with several printers but the problem is always the same.
    What I can do to solve this problem?
  2. Ralitsa
    Admin
    Ralitsa avatar
    190 posts

    Posted 20 Jan 2014 Link to this post

    Hi Felice, 

    Thank you for contacting us. 

    You need to set the AutoSizeRows property which is indicating whether row height in a RadGridView will expand for multiline cell text. You can set the AutoSizeRows property to true before printing and set it back to false when the dialog closes, or you can have it set to true all the time.

    Unfortunately we also have a bug logged in our Public Issue Tracking System related to this property. 
    You can read more about it, vote and subscribe for changes on this address: PITS issue. The issue will be resolved in our future releases. 

    Currently, the possible workaround is to scroll to the bottom of the grid and then restore the scroll's value so that you wouldn't notice it has been moved. Please take a look at the following example: 
    private void radButton1_Click(object sender, EventArgs e)
    {
        this.radGridView1.AutoSizeRows = true;
     
        GridPrintStyle style = new GridPrintStyle();
        style.FitWidthMode = PrintFitWidthMode.FitPageWidth;
        style.PrintHeaderOnEachPage = true;
        this.radGridView1.PrintStyle = style;
     
        int save = this.radGridView1.TableElement.VScrollBar.Value;
        this.radGridView1.TableElement.ScrollTo(this.radGridView1.Rows.Last().Index, this.radGridView1.Columns.Last().Index);
        this.radGridView1.TableElement.VScrollBar.Value = save;
     
        this.radGridView1.PrintPreview();
    }

    I hope this will help. Do not hesitate to write back with further questions.

    Regards,
    Ralitsa
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top