Hi,UltraGridDocumentExporter1.Export(Me.ugvDataGrid, MyPath, DocumentExport.GridExportFileFormat.PDF) don't work when i put this line in a second thread .... why ?The thread procédure:Private Sub ThreadProcedure() Try _ugePDF.Export(_Grid, _Chemin, DocumentExport.GridExportFileFormat.PDF) Finally End Try End SubTo launch the thread: Public Sub Exporter() _ExportThread = New Thread(New ThreadStart(AddressOf ThreadProcedure)) _ExportThread.IsBackground = True _ExportThread.Start() End SubIt's working with ExcelExporter ...
Perhaps that's wrong?:
Public Sub New(ByVal uGrid As UltraGrid)
_ugePDF = New UltraGridDocumentExporter_Grid = uGrid_ugePDF.TargetPaperOrientation = Infragistics.Documents.Report.PageOrientation.Landscape_ugePDF.TargetPaperSize = Infragistics.Documents.Report.PageSizes.Letter_ugePDF.ImageCompressorType = ImageCompressorType.Flate_ugePDF.AutoSize = AutoSize.None_ugePDF.UseFileBuffer = False
End Sub
Excellent !
Thank from France ! :)
There are 2 main hurdles you'll need to overcome to create a purely in memory grid (ie. not on a form). You'll want to manually call CreateControl to get the component 'started'. After that you'll need to assign the grid a new BindingContext(). These steps are normally automatic when the grid is part of a form but since in this case we're working withouth a form or "site", we'll need to perform these steps. Below is a code snippet that should work to create a grid. Just fill in your data and you're set.
grid.CreateControl();
grid.DataSource = //your data
Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter exporter = new Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter();
exporter.Export(grid, "c:\\temp.pdf", Infragistics.Win.UltraWinGrid.DocumentExport.GridExportFileFormat.PDF);
thank you very mutch !
You do have a couple alternatives.
1) In your separate thread you can use the DocumentEngine itself to create a PDF from scratch (w/out using the GridExporter). The DocumentExporter is simply a shortcut which leverages the DocumentEngine APIs to generate a PDF from your grid instance. It would be a bit of grunt work, but it's a possible solution to generating a PDF on a separate thread.
2) Alternatively, you can create a Grid, DataSource and Exporter all on your separate thread. Since the controls will all be part of the same thread, using the exporter is no longer a concern. There are a couple of hurdles with this approach though. You'll need to transfer any of your grid settings over (grouping, sorting, filter, etc.) since the 2nd grid is completely independant of the main UI. You may also need to force the Grid through some of its lifecycle like CreateControl.
Hope this helps,
-Tony