Microsoft KB Archive/816799

= &quot;Can't create a child list&quot; error message occurs when you open a form in Visual Studio .NET =

Article ID: 816799

Article Last Modified on 5/12/2007

-

APPLIES TO


 * Microsoft ADO.NET 1.0
 * Microsoft ADO.NET 1.1
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition

-





Beta Information
This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location where you downloaded the release.



SYMPTOMS
When you delete the table that is bound to a control form of the DataSet Schema and then save the project in Microsoft Visual Studio .NET, you may receive the following error message when you open the form in Design view:

Can't create a child list for field.

The controls that are added before the data bound control are deleted from the form by Visual Studio .NET, and you receive the following error message in the data bound control:

System.ArgumentException: Can't create a child list for field.



CAUSE
In Windows Form Designer-generated code, the controls are displayed on the form when the Control array is added to the Controls collection of the form. The last control that is added to the form has the index 0 in the Control array, the first control has the highest index, and then the other controls. When the XML Schema is changed, the data bound control raises an error and the controls that were added to the form before the data bound control are removed from the array because the controls are after the data bound control in the Control array. Therefore, the controls are not added to the Controls collection of the form and are not displayed.



WORKAROUND
To work around this problem, do not save the project after you delete the table from the DataSet Schema file. Open the Windows Form, and then set the DataSource property and the DisplayMember property of the bound control to none. If the controls are lost, you can add controls manually to the Controls collection of Form1. To do this for the sample application that is used in the &quot;More information&quot; section of this article, follow these steps:  Right-click Form1, and then click View Code.  In the InitializeComponent procedure of the Windows Form Designer generated code region, locate the following statement in the Form1 code:

Microsoft Visual Basic .NET code Me.Controls.AddRange(New System.Windows.Forms.Control {Me.TextBox2, Me.TextBox1, Me.ListBox1}) Microsoft Visual C# .NET code this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox2,this.textBox1,this.listBox1});   Add the name of the missing controls:

Visual Basic .NET code Me.Controls.AddRange(New System.Windows.Forms.Control {Me.TextBox2, Me.TextBox1, Me.Button2,Me.Button1,Me.ListBox1}) Visual C# .NET code this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox2,this.textBox1,this.button1,this.button2,  this.listBox1}); 



STATUS
This behavior is by design.



Steps to reproduce the behavior
 In Visual Studio .NET, create a new Windows Application by using Visual Basic .NET or Visual C# .NET. By default, Form1 is created.</li> Create a new data connection. To do this, follow these steps:  On the View menu, click Server Explorer.</li> In Server Explorer, right-click Data Connections, and then click Add Connection.</li> In Data Link Properties window, click the Connection tab.</li> Type the name of the local computer that is running SQL Server in the Select or enter a server name box, and then click NorthWind in the Select the database on the server list.</li></ol> </li> In the Toolbox, click the Data tab, and then add a SqlConnection control to Form1.</li> Right-click the SqlConnection1 control, and then click Properties.</li> In the Properties window, set the value of the ConnectionString property to the data connection that was created in step 2.</li>  Add a SqlDataAdapter control to Form1. In the Data Adapter Configuration Wizard, click Next three times, and then type the following SQL statement: select * from Customers </li> Click Next, and then click Finish to close the wizard.</li> Right-click SqlDataAdapter1, and then click Generate Dataset. Click OK.</li> Finish adding controls to the form. To do this, follow these steps:  Add two Button controls to Form1.</li> <li>Add a ListBox control to Form1.</li> <li>Right-click ListBox1, and then click Properties.</li> <li>In Properties window, set the value of the DataSource property to DataSet11, and then set the value of the DisplayMember property to Customers.CustomerID.</li> <li>Add two TextBox controls to Form1.</li></ol> </li> <li>On the View menu, click Solution Explorer.</li> <li>In Solution Explorer, double-click DataSet1.xsd.</li> <li>Right-click the Customers table, and then click Delete.</li> <li>On the File menu, click Save All to save the project.</li> <li>Double-click Form1.vb to open Form1. The error message that was mentioned in the &quot;Symptoms&quot; section of this article appears and all the controls that were added to Form1 before ListBox1 was added are removed.</li></ol>

<div class="references_section">