Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Printing Grid.
posted

Hi,

Can you please let me know if this is possible in grid printing.

I have a grid with 8 columns. There is just one row in the grid .Due to the text size and width of the columns the grid prints 5 columns in page 1 and 3 columns in page 2.

I would like to print 5 columns, followed by the other 3 columns on the same page . This would help in not seeing much of white spaces between the 2 pages, as there is just one row of data and the grid can as well use the space left behind in page 1. 

Output currently is

Page 1

column 0 column1 column2 column3 column4

-------------data------data------data------

Page 2

column5  column6  column7

---data------data------data------

 

Expected output

Page 1

column 0 column1 column2 column3 column4

-------------data------data------data------

column5  column6  column7

--data------data------data------

 

Thank you.

Parents
  • 469350
    Offline posted

    Hi,

    The grid can't automatically wrap a row onto a page.

    But if you know how many columns fit on a page, you could adjust the layout of your grid so that the columns in the row are one atop the other using either Groups and Levels or RowLayouts.

    You can do this on the print layout which is passed into the InitializePrint or InitializePrintPreview events so that it does not affect the layout of the on-screen grid.

    Setting up a RowLayout at run-time can be pretty tricky if you are not already familiar with GridBagLayouts. So here's some sample code.


            private void ultraGrid1_InitializePrintPreview(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintPreviewEventArgs e)
            {
                UltraGridBand band = e.PrintLayout.Bands[0];
                band.RowLayoutStyle = RowLayoutStyle.ColumnLayout;
               
                // Columns 0 through 4 are fine where they are, so we don't need to do anything to them.
                // Adjust columns 5-7 so they are under 0-2.
                for (int i = 5; i < 8; i++)
                {
                    UltraGridColumn columnInTopRow = band.Columns["Column " + (i - 5).ToString()];
                    UltraGridColumn columnUnderneath = band.Columns["Column " + i.ToString()];

                    columnUnderneath.RowLayoutColumnInfo.OriginX = columnInTopRow.RowLayoutColumnInfo.OriginXResolved;
                    columnUnderneath.RowLayoutColumnInfo.SpanX = columnInTopRow.RowLayoutColumnInfo.SpanXResolved;
                    columnUnderneath.RowLayoutColumnInfo.OriginY = columnInTopRow.RowLayoutColumnInfo.OriginYResolved + columnInTopRow.RowLayoutColumnInfo.SpanYResolved;
                }
            }

     

     

Reply Children