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
50
UltraWinGrid Export Error
posted

Hello. I have several grids bound to various different datasources, all of which use the Excel exporting functionality. However, one of the grids encounters an error every time I try to perform an Excel export. For this particular grid, it is bound directly to a typed DataTable in a typed DataSet, without a BindingSource. There is one unbound column in the grid. Below is the exception:

 

System.ArgumentException: Key already exists
Parameter name: Key
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key, IKeyedSubObject ignoreObject)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.InternalAdd(IKeyedSubObject obj)
   at Infragistics.Win.UltraWinGrid.ColumnsCollection.InternalAdd(UltraGridColumn column)
   at Infragistics.Win.UltraWinGrid.UltraGridBand.InitColumns(UltraGridBand[] oldBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[] oldBands)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()
   at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter)
   at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Worksheet worksheet, Int32 startRow, Int32 startColumn)
   at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Workbook workbook)
   at MyApp.WinForms.Controls.BaseControl.ExportGrid(UltraGrid grid, String title, String initDirectory, Boolean promptToOpen) in D:\Development\MyApp\MyApp.WinForms\Controls\BaseControl.cs:line 882

 

I am using Infragistics v10.2. Any insight or help you can provide would be greatly appreciated.

Thanks!

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    From the call stack, it appears that the exception occurs when the grid is trying to bind the export layout to the same data source that the real grid is bound to. Which is very odd, since I assume the actual on-screen grid doesn't have any problems like this.

    My best guess is that something in your code is trying to re-add the unbound column into the export layout even though it already exists. Are you adding your unbound column in code? If so, what event are you using?

    Try setting the Visual Studio IDE to break on all run-time exceptions. I'm guessing that the call stack you have here is not really the problem, but that the real exception is occurring and being caught somewhere else.

Children