Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1871
Issue exporting multiple grids.
posted

This is the logic I am using to create a workbook and then I save the workbook.

 

Infragistics.Excel.Workbook workBook = new Infragistics.Excel.Workbook();

 

ultraGridExcelExporter.Export(this.ultraGrid1, workBook.Worksheets.Add("Orders"));

ultraGridExcelExporter.Export(this.ultraGrid2, workBook.Worksheets.Add("POS Payment Totals"));

 

SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();

saveFileDialog1.DefaultExt = "xls";

 

saveFileDialog1.FileName = "Order Inquire Export on " + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year;

 

saveFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";

saveFileDialog1.RestoreDirectory = true;

 

if (saveFileDialog1.ShowDialog() == DialogResult.OK)

{

workBook.Save(saveFileDialog1.FileName);

}

 

saveFileDialog1.Dispose();

saveFileDialog1 = null;

workBook.Worksheets.Clear();

 

The issue I an having is ultraGrid2 is in a dock manager and is set to auto hide. If the flyout comes out the grid is initialized and the export works great. However if I never open up the grid then nothing is ever exported to the worksheet.

Any suggestions on how I can make this work with or without showing the grid?

 

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    My guess is that your second grid is not parented to any form or other container control, so it therefore has no BindingContext. Once you expand the DockPane, it gets parented to the pane and has a BindingContext at that point.

    The easiest way to fix this is to set the grid's BindingContext to the BindingContext of the form. I'd try doing this in Form_Load, or possibly right after you create the grid if you are creating it in code.

Children