Hi,
I need to create new grid dinamically and to copy all the selected rows from already existing grid to this new grid. How to copy these rows into new grid (including of course band schema)... Or better yet, my problem is that I need to export to excel only selected rows (this is the original issue...).
Many thanks in advance,
Cheers,
Igor
Hi Igor,
If you want to export only selected rows to Excel, then there is a far easier way to do it than creating a whole new grid. All you have to do is hide the unselected rows during the export process. The obvious place to do this is in the RowExprting event of the UltraGridExcelExporter.
However, there is a small caveat. In order to allow you to modify things in the export without modifying the on-screen grid, the exporter creates a clone of the grid layout and clones of the rows. So you if you check e.GridRow inside this event and examine the Selected property of the row, it will never be selected, because it's not the "real" row. So you have to get the real row in order to determine it's selected state. So the code looks like this:
private void ultraGridExcelExporter1_RowExporting(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.RowExportingEventArgs e) { UltraGrid grid = e.GridRow.Band.Layout.Grid as UltraGrid; UltraGridRow realGridRow = grid.GetRowFromPrintRow(e.GridRow); if (realGridRow.Selected == false) e.Cancel = true; }