I have a Hierarchical Datagrid from version 12.1.
I load a collection of class Employee in de Datasource. Each Employee has a property Tasks which is a collection of class Task.The property Tasks however is always initially empty (so the grid is 1 level deep).
In my app the enduser can assign a Task to an Employee. The Task row needs to be shown beneath the Employee row, this all works fine. But I also need to autosize all the columns of all the rows. And I want to size everything so that all the data in the cells are visible to the enduser.
I try to do this in the InitializeLayout eventhandler, as follows:
private void ultraGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { Infragistics.Win.UltraWinGrid.UltraGrid grid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender; grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False; grid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect; grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single; Infragistics.Win.UltraWinGrid.UltraGridLayout layout = e.Layout; Infragistics.Win.UltraWinGrid.UltraGridOverride ov = layout.Override; ov.AllowColSizing = Infragistics.Win.UltraWinGrid.AllowColSizing.Free; layout.Bands[0].Override.RowSpacingAfter = 2; layout.Bands[0].Override.RowSpacingBefore = 3; foreach (var band in layout.Bands) { band.PerformAutoResizeColumns(false, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand); foreach (var col in band.Columns) { col.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand, true); } } }
The PerformAutoResize in the foreach loop is not giving me the result I expected. The added Tasks at level 2 in the grid are not resized at all so it seems. Can you please help me Infragistics? I need your expert advice on this one.
On one of post it mentined like this :The best thing to do is to leave on the AutoSize property or auto-size the columns in the export layout to ensure that the data will fit in the report.
So how to do autosize column ? is it same like this ?
ugrdExporter.AutoSize = Infragistics.Win.UltraWinGrid.DocumentExport.AutoSize.SizeColumnsToContent
I am using 13.1.20131.2060 version.
Hi,
I'm not sure if BeginExport is any better. That event is obsolete, so you might try ExportStarting, but event that might be too late. The best thing to do is to set the property before you call the Export method. I typically set it at design-time.
If that still doesn't work, then my best guess is that there is something about your data or your grid settings which is causing the autosizing to fail. What version of the controls are you using?
If you can post a small sample project demonstrating the problem, we would be happy to check it out.
Thanks for quick reply, So now I am doing like this still it's not working.
Private Sub ugrdExporter_BeginExport(sender As Object, e As Infragistics.Win.UltraWinGrid.DocumentExport.BeginExportEventArgs) Handles ugrdExporter.BeginExport
ugrdExporter.AutoSize = Infragistics.Win.UltraWinGrid.DocumentExport.AutoSize.SizeColumnsAndRowsToContent
End Sub
The AutoSize property on the exporter needs to be set before the export operation begins. You can't set it in these events - it's too late by then.