'What does "Child list for field ... cannot be created" mean?
My C# coded application uses an Infragistics.Win.UltraWinGrid.UltraGrid to display some data. The data is basically a collection of computers. The application is able to filter these computers (like "Workstations", "Servers" etc) for viewing. This is how I filter:
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;
}
Note that I set the table name to a potentially huge filter string.
This is how I use the above method:
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);
Everything upto that point is fine. UltraGrids have a facility that allows you to choose which columns you want hidden and create new custom columns. When this facility is started an event of the UltraGrid called BeforeColumnChooserDisplayed is fired. Here's my handler:
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;
}
And here is the ShowCustomColumnChooserDialog method implementation:
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 is basically a form which adds a little extra to the Infragistics default one. The most important thing that it's code takes care of is this method:
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;
}
If I step through the code, it's all cool until I exit the event handler (the point at which the control returns to the form). I get an ArgumentException thrown at me only when I try and show the CustomColumnChooser dialog from a grid that displays filtered data. Not the kind that shows the offending line in your code, but the type that brings up a "Microsoft .NET Framework" error message box that says "Unhandled exception has occurred in your application...". This means I can't trace what's causing it. The app doesn't fall apart after that, but the would-be CustomColumnChooser dialog comes up with the container containing nothing but a white background and a big red "X".
And the stack trace:
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)
Child list for field DiscoveryData([Build] = '4 cannot be created is not very helpful. What does it really mean?
Solution 1:[1]
Check you DataBindings.
The problem is often caused due to your binding path. If you have something like this:
labelFirstName.DataBindings.Add("Text", "_Person.Info.FName", true, DataSourceUpdateMode.OnPropertyChanged);
you will probably have to update it to another Add-method overload:
labelFirstName.DataBindings.Add("Text", _Person.Info, "FName", true, DataSourceUpdateMode.OnPropertyChanged);
Solution 2:[2]
I created a new DataSet and create the tables and columns from scratch, then deleted the DataSet that gave this exception, and rename the new with the name of the deleted.
Now it works again.
My situation was this
I dropped a DataSet on my form, and in the visual designer added 2 tables with each 2 columns
In runtime the tables are populated, the data is never saved.
This worked well, until one day I got the same exception as the OP.
So, what changed ?
well, nothing, absolutely nothing at all.
The form was open in VS but no changes where made
I get this often, VS seems to change something in open files, and does not tells me what it changed or lets me know that it changed something,
SVN also did not detect any change,
Now the problem is that VS makes changes that do compile, but the visual designer has big problems with them.
I wish they would stop doing that...
Ow yes, before I forget,
my exception was
Child list for field "project" cannot be created
The funny thing is, I have no field called project !
I do have another dataset which has a table called project, but the exception did not occur on that dataset.
On the DataSet with the problem, there is no field called Project, and no table called Project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | juFo |
| Solution 2 | GuidoG |
