Hi,
I generate a report from a DataGrid, where each row on the windows form is display as we wan't.
private void gridAEA_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns; e.Layout.Override.RowSizing = Infragistics.Win.UltraWinGrid.RowSizing.AutoFree; e.Layout.Override.RowSizingArea = RowSizingArea.EntireRow; e.Layout.Override.CellMultiLine = Infragistics.Win.DefaultableBoolean.True;
...
}
If the cell width is smaller than the text inside, it's display on several rows.
But, when we print the report using his print method, the data in cells are not all dispaly. It is on display multiLine only if the largest cells have data on several lines (like it's explain on the propertie : Infragistics.Win.UltraWinGrid.RowSizing.AutoFree).
Why is it display as we wan't on the DataGrid (in the WinForm) and not when we print ?
Do you have a solution to print the Report (from datagrid) as we wan't ? It seems that the row adapt itself if one of it cells is display on multiLine.
Best Regards,
Denis
Hi Denis,
When you print the grid, it's going to print using the same sizes for columns and rows that the on-screen grid has. The problem with this is that the printer uses different units (points instead of pixels), so things don't always come out exactly right.
I'm having a little trouble understanding the behavior you want, but it seems to me like you need to autosize the printed rows.
What you could do is place code in the InitializeRow event of the grid and check e.Row.Band.Layout.IsPrintLayout. This will tell you if the row is a print row or an on-screen row. If it's a print row, you can call PerformAutoSize on the row and it will size the row based on the printer units.
You could do the same thing with the columns inside InitializePrint or InitializePrintPreview - if the colmun widths are a problem.
Thanks for your answer, but it's not exactly what i needs.
In fact, i put the DataGrid in a Report because i wan't to make my own presentation, in order to print it after.
i couldn't enter in the event InitializePrint() beacause i print a report and not directly the DataGrid.
The solution I found is to save rows height in a list on the DataGrid event : dataGrid_InitializeRows() and after I use it in UltraGridDocumentExporter event : ultraGridDocumentExporter1_InitializeRow() :
e.Row.PerformAutoSize(); e.Row.Height = listHauteurLigne[e.Row.Index];
It works now but it's not a really beautifull solution!
Tell me if you have a better solution.
Thanks,
Best regards,