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
310
SetDataBinding is not working on adhoc UltraGrid
posted

I am trying to create a component in our application that encapsulates the UltraGridExcelExporter. This control works so well for grid data... I was looking to use it to simplify Excel file creation for any data source. Here is the code I would like to write, but it proves to be problematic in as much as getting the data to bind to the dynamically created instance of the UltraGrid. Debugging the below code I find that SetDataBinding  does not bind to the grid. What am I missing?

      _wb = new Workbook();
      var ws = _wb.Worksheets.Add( sheetName );
      var dt = GetDataTable();
      var ultraGrid = new UltraGrid();
      ultraGrid.DataBindings.Clear();
      ultraGrid.SetDataBinding( dt, "" );
      ultraGrid.DisplayLayout.Bands[0].Override.RowAlternateAppearance.BackColor = Color.LightGray;
 
      var excelExporter = new UltraGridExcelExporter();
      excelExporter.Export( ultraGrid, ws );
      excelExporter.Dispose();
      _wb.Save( fileName );

Thanks in advance,

Kent