It does not appear that the UltraGridPrintDocument is supporting the GroupBy presentation of an UltraGrid. The GroupBy row headings don't appear in the print preview, nor do the data columns that contain the data for the GroupBy rows appear. I would have hoped that this was a setting in the RowPropertyCategories enum of the RowProperties. Am I correct in assuming GroupBy rows are not supported by the UltraGridPrintDocument?
Mike, That workaround was perfect. Thanks for bearing with me in this back and foth. I know the UltraGrid is quite a complex component, and I may be using it in odd ways. But the flexibility allows me to use it in many different ways.
While I am at it, no need to respond, but I wanted to say how pleased I am with the combination of the UltraPrintPreview and Thumbnail controls. The functionality in the preview control made it extremely easy for me to put together my own preview dialog where I allow the user to pick and choose many different elements to include in the report being generated. And I am using a Document to generat the report with the report pages converted to a metafile stream for use in the UltraPrintDocument. This grid, which I am using for a flow sheet, is the only element I have to separately deal with in a separate GridDocument. But I am using my same dialog that includes the preview and thumbnail controls along with my element selectors. I especially like the idea of clicking different regions of the thumbnail image to automatically move that region of the preview into view. Kudos for that.
Hi Roy,
Thanks for the sample. I was able to track this down.
When the grid prints, it creates a clone of the layout. When the layout is cloned, it''s creating a new set of bands and column and also cloning the SortedColumns collection on the band.
When it does this, it's firing off the BeforeSortChanged event as the new (cloned) columns are added to the cloned SortedColumnsCollection. I don't think the event should be firing at this point - that seems like a bug to me. But since it is firing and your code is cancelling the event, the columns do not get sorted and therefore they do not get grouped (since sorting and grouping are closely tied together).
So, I'm going to forward this thread over to Infragistics Developer Support so they can get the issue of the event firing fixed.
In the mean time, you can work around this very easily by modifying your BeforeSortChange event and bailing out if the layout is a print layout:
Private Sub ugFlowSheet_BeforeSortChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs) Handles ugFlowSheet.BeforeSortChange If e.Band.Layout.IsPrintLayout Then Exit Sub ' If loading the grid, allow the sorting used for GroupBy If (mbolLoading) Then Exit Sub ' Do not allow any user column sorting e.Cancel = True End Sub
Mike, I have uploaded a VS2008 VB project that can be used to evaluate the lack of GroupBy rows in the print preview. All you need to do is to select the load grid, choose the grid1.txt file, which will load the grid up. The print grid button dos that simplistic invocation of the printpreview dialog. Perhaps the problem I am having is because I o not set the grid into GroupBy mode in the InitializeLayout handler because I cannot do it there. I use this grid by directly loading data and control the grid schema with a DataTable that has no data rows. As soon as the grid's atasource is set to the table, the InitializLayout is called. If the grid has no data, an attempt o set the GroupBy olumns results in an error. So the grid is put into GroupBy mode after the grid is populated. But this should be no different than if a user controlled the grouping by dragging the column with the mouse to the GroupBy location. I do not allow that to be shown here as I am controlling the grouping.
Hi,
I tried this out with the same code you have here and it works fine for me. The Print Preview shows the grid exactly as it is on-screen with the groupby rows.
So either something in your code is modifying the layout in some way, or this is a bug in the version you are using that has already been fixed.
I recommend that you get the latest service release: How to get the latest service release - Infragistics Community
If that doesn't help, then we will need you to create a small sample project demonstrating the problem and post it here so we can check it out.
Here is a more simple piece of code I am using to test out the UltraGridPrintPreview; the grid is the same as what I previously posted. I am not doing anything in the printing events as I did not see anything in the documenhtation that showed I needed to do any more than this. So if there is additional code, please let me know what it is.
Dim Dlg As Printing.UltraPrintPreviewDialog = New Printing.UltraPrintPreviewDialog Dim GridDoc As UltraGridPrintDocument = New UltraGridPrintDocument Try GridDoc.Grid = ugFlowSheet Dlg.Document = GridDoc Dlg.ShowDialog(Me) Dim f As New PrintDlg Catch ex As Exception PostError(ex) End Try