Che cosa significa “lista del bambino per il campo ... non può essere creato” significa?

StackOverflow https://stackoverflow.com/questions/1130364

  •  13-09-2019
  •  | 
  •  

Domanda

La mia applicazione C # in codice utilizza un Infragistics.Win.UltraWinGrid.UltraGrid per visualizzare alcuni dati. Il dato è sostanzialmente un insieme di computer. L'applicazione è in grado di filtrare questi computer (come "stazioni di lavoro", "Server", ecc) per la visualizzazione. Questo è il modo a filtrare:

private DataView FilterTableDataForViewing(DataTable originalTable, string filterString, UltraGrid viewGrid)
    {
        DataView dataView = new DataView(originalTable);
        dataView.RowStateFilter = DataViewRowState.CurrentRows;
        dataView.RowFilter = filterString;

        DataTable filteredTable = dataView.ToTable(originalTable.TableName + "_" + dataView.RowFilter);
        viewGrid.DataSource = filteredTable;
        gridDiscoveryMain.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
        SetFlagImagesAndColumnWidthsOfDiscoveryGrid();
        return dataView;
    }

Nota che ho impostato il nome della tabella a una stringa di filtro potenzialmente enorme.

Questo è come io uso il metodo di cui sopra:

string filterString = "([Build] = '4.0' AND NOT([OS Plus Version] LIKE '%Server%'))";
            filterString += " OR ([Build] = '4.10')";
            filterString += " OR ([Build] = '4.90')";
            filterString += " OR ([Build] = '5.0' AND NOT([OS Plus Version] LIKE '%Server%'))";
            filterString += " OR ([Build] = '5.1')";
            filterString += " OR ([Build] = '6.0' AND ";
            filterString += "(NOT([OS Plus Version] LIKE '%Server%')) OR (NOT([OS] LIKE '%Server%')))";
            FilterTableDataForViewing(dataSet.Tables["DiscoveryData"], filterString, gridDiscoveryMain);

Tutto ciò fino a che punto è bene. UltraGrids hanno una struttura che consente di scegliere quali colonne desideri nascosti e creare nuove colonne personalizzate. Quando si avvia questa struttura viene sparato un evento del UltraGrid chiamato BeforeColumnChooserDisplayed. Ecco il mio gestore:

private void gridDiscoveryMain_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e)
    {
        if (gridDiscoveryMain.DataSource == null)
            return;

        e.Cancel = true;
        gridDiscoveryMain.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;
        gridDiscoveryMain.DisplayLayout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton;
        ShowCustomColumnChooserDialog();
        this.customColumnChooserDialog.CurrentBand = e.Dialog.ColumnChooserControl.CurrentBand;
        this.customColumnChooserDialog.ColumnChooserControl.Style = ColumnChooserStyle.AllColumnsWithCheckBoxes;
    }

E qui è l'implementazione del metodo ShowCustomColumnChooserDialog:

private void ShowCustomColumnChooserDialog()
    {
        DataTable originalTable = GetUnderlyingDataSource(gridDiscoveryMain);
        if (this.customColumnChooserDialog == null || this.customColumnChooserDialog.IsDisposed)
        {
            customColumnChooserDialog = new CustomColumnChooser(ManageColumnDeleted);
            customColumnChooserDialog.Owner = Parent.FindForm();
            customColumnChooserDialog.Grid = gridDiscoveryMain;
        }

        this.customColumnChooserDialog.Show();
    }

customColumnChooserDialog è sostanzialmente una forma che aggiunge un po 'di più per l'impostazione predefinita Infragistics uno. La cosa più importante che è il codice si prende cura di questo metodo è:

private void InitializeBandsCombo( UltraGridBase grid )
    {
        this.ultraComboBandSelector.SetDataBinding( null, null );
        if ( null == grid )
            return;

        // Create the data source that we can bind to UltraCombo for displaying 
        // list of bands. The datasource will have two columns. One that contains
        // the instances of UltraGridBand and the other that contains the text
        // representation of the bands.
        UltraDataSource bandsUDS = new UltraDataSource( );
        bandsUDS.Band.Columns.Add( "Band", typeof( UltraGridBand ) );
        bandsUDS.Band.Columns.Add( "DisplayText", typeof( string ) );

        foreach ( UltraGridBand band in grid.DisplayLayout.Bands )
        {
            if ( ! this.IsBandExcluded( band ) )
            {
                bandsUDS.Rows.Add( new object[] { band, band.Header.Caption } );
            }
        }

        this.ultraComboBandSelector.DisplayMember = "DisplayText";
        this.ultraComboBandSelector.ValueMember= "Band";
        this.ultraComboBandSelector.SetDataBinding( bandsUDS, null );

        // Hide the Band column.
        this.ultraComboBandSelector.DisplayLayout.Bands[0].Columns["Band"].Hidden = true;

        // Hide the column headers.
        this.ultraComboBandSelector.DisplayLayout.Bands[0].ColHeadersVisible = false;

        // Set some properties to improve the look & feel of the ultra combo.
        this.ultraComboBandSelector.DropDownWidth = 0;
        this.ultraComboBandSelector.DisplayLayout.Override.HotTrackRowAppearance.BackColor = Color.LightYellow;
        this.ultraComboBandSelector.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
        this.ultraComboBandSelector.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid;
        this.ultraComboBandSelector.DisplayLayout.Appearance.BorderColor = SystemColors.Highlight;
    }

Se io passo attraverso il codice, è tutto fresco fino a quando esco il gestore di eventi (il punto in cui il controllo ritorna al modulo). Ottengo un ArgumentException gettato su di me solo quando provo e mostrare la finestra di dialogo CustomColumnChooser da una griglia che visualizza dati filtrati . Non è il tipo che mostra la linea incriminata nel codice, ma il tipo che porta in primo piano una finestra di messaggio di errore "Microsoft .NET Framework" che dice "L'eccezione non gestita si è verificato nell'applicazione ...". Ciò significa che non posso tracciare quale è la causa. L'applicazione non cade a pezzi dopo che, ma la finestra di aspiranti CustomColumnChooser esce con il contenitore contenente nient'altro che uno sfondo bianco e un grande "X" rossa.

E l'analisi dello stack:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Child list for field DiscoveryData_([Build] = '4 cannot be created.
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.get_Item(Object dataSource, String dataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()
   at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBindingHelper(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.CreateColumnChooserGridDataStructure()
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.Initialize()
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.VerifyInitialized()
   at Infragistics.Win.UltraWinGrid.ColumnChooserGridCreationFilter.BeforeCreateChildElements(UIElement parent)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.InternalInitializeRect(Boolean verify)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.GetUIElement(Boolean verify, Boolean forceInitializeRect)
   at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Bambino per DiscoveryData campo ([costruire] = 'Non è possibile creare 4 non è molto utile. Cosa significa veramente?

È stato utile?

Soluzione

Io non sono troppo bene su WinForms e non ho mai usato Infragistics Ultragrid. La mia ipotesi è che Bambino per DiscoverData campo ([costruire] = '4 è gettato in fondo nel quadro di una parte del codice di associazione dati. Sembra di essere alla ricerca di membri figlio di un classe denominata ([costruire] = '4 come si ferma al punto o punto (.) nella stringa letterale.

Io cerco di evitare di lavorare con DataSets e DataViews causa di alcuni dei cerchi pazzi che saltano attraverso.

Potrebbe valere la pena di cottura fino riflettore e avere un poke intorno System.Windows.Forms.BindingContext

Altri suggerimenti

Controlla tu DataBindings.

Il problema è spesso dovuta a causa di vostro percorso vincolante. Se avete qualcosa di simile:

labelFirstName.DataBindings.Add("Text", "_Person.Info.FName", true, DataSourceUpdateMode.OnPropertyChanged);

probabilmente si dovrà aggiornare ad un altro overload Add-metodo:

labelFirstName.DataBindings.Add("Text", _Person.Info, "FName", true, DataSourceUpdateMode.OnPropertyChanged);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top