I have a grid that I'm trying to export to a PDF file. For the exported PDF I want to apply a different layout to the grid during export. To do this I planned on adding logic to the grid InitializeLayout that would check for the flag and apply the proper layout properties.
My question is when/how is the InitializedLayout event triggered here. I was expecting that the Export method or something after the BeginExport would trigger a new InitializeLayout but that does not appear to be the case.
My current code to do the export looks like ...
...do some stuff
Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter tableExporter = new Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter
();
tableExporter.BeginExport += new EventHandler<Infragistics.Win.UltraWinGrid.DocumentExport.BeginExportEventArgs>(tableExporter_BeginExport
);
tableExporter.CellExported += new EventHandler<Infragistics.Win.UltraWinGrid.DocumentExport.CellExportedEventArgs>(tableExporter_CellExported
tableExporter.EndExport += new EventHandler<Infragistics.Win.UltraWinGrid.DocumentExport.EndExportEventArgs>(tableExporter_EndExport
tableExporter.RowExporting += new EventHandler<Infragistics.Win.UltraWinGrid.DocumentExport.RowExportingEventArgs>(tableExporter_RowExporting
tableExporter.Export(reportGrid, report);
... clean up
I also have a BeginExport event handler that adds a standard header/footer and page numbers and then returns. Perhaps there is something I should be doing in the BeginExport handler to trigger what I need.
Thanks
Neil
You can make changes to the layout in the BeginExport event handler by using e.Layout.
Thanks for the repoly. Is there any way to cause the defined grid initializelayout event to fire without resetting the data source (set it to null and then back to the original or something).
My problem with trying to do things in the BeginExport is that I have a general event handler in a class that does standard export setup. The method is passed a grid and puts standard header/footer stuff on it and then does the export based on type (Excel, PDF, etc.). This method does not have any knowledge of the grid it is handling or the layout required. The InitializeLayout event in the win form that holds the grid knows all that stuff so want I need to be able to do is figure out how ti invoke (or really, have the grid refire) initializelayout so that the proper method in the form that owns the grid is called.
From your response, I am guessing that there is no way to do what I need here.
IG Docs says that InitializeLayout:
"Occurs when the display layout is initialized, such as when the control is loading data from the data source"
so obviously, it doesn't belong to export layout.
I think reseting the data source is not a good way.
You can solve it like that:
1. Make an Interface that has a method that arranges the layout.
2. Implement that interface in the form.
3. In BeginExport check if e.Layout.Grid.FindForm() implements this interface and invoke the method.
Ok, thanks. I'll look at doing something like that here. I guess then my question is, what is the purpose of the IsExportLayout property or the IsPrintLayout property if the only time that the initializelayout event is called (unless you do something like your suggestion) is when the grid is being displayed. It would seem that the only place you would see this set is in one of the Export events (like BeginExport) where you already know you are in an export so it does not add a lot of value. I must be missing the purpose of the property.
I understand how to check for it I was more asking what good it was. From your response I'm assuming that intended use is if you need to set some specific values or change cell formatting or something like that in the InitializeRow event. From the name of the property I was assuming that it was to be used when the Layout event was fired to tell you the type of layout to do. That would seem (to me) to be more useful (at least as useful) as knowing that fact in Initialze Row.
Thanks for the explanation though.
In InitializeRow event you can check it by:
e.Row.Band.Layout.IsExportLayout
You can use that event in the form, but it is fired for each row.