Microsoft Knowledge Base Email Alertz

KBAlertz.com: (816799) - 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...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]






Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

"Can't create a child list" error message occurs when you open a form in Visual Studio .NET

Article ID:816799
Last Review:May 12, 2007
Revision:1.3
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.
On This Page

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 TableName.

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 TableName.

Back to the top

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.

Back to the top

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 "More information" section of this article, follow these steps:
1.Right-click Form1, and then click View Code.
2.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});
3. 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});

Back to the top

STATUS

This behavior is by design.

Back to the top

MORE INFORMATION

Steps to reproduce the behavior

1.In Visual Studio .NET, create a new Windows Application by using Visual Basic .NET or Visual C# .NET. By default, Form1 is created.
2.Create a new data connection. To do this, follow these steps:
a. On the View menu, click Server Explorer.
b. In Server Explorer, right-click Data Connections, and then click Add Connection.
c. In Data Link Properties window, click the Connection tab.
d. 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.
3.In the Toolbox, click the Data tab, and then add a SqlConnection control to Form1.
4.Right-click the SqlConnection1 control, and then click Properties.
5.In the Properties window, set the value of the ConnectionString property to the data connection that was created in step 2.
6.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
7.Click Next, and then click Finish to close the wizard.
8.Right-click SqlDataAdapter1, and then click Generate Dataset. Click OK.
9.Finish adding controls to the form. To do this, follow these steps:
a. Add two Button controls to Form1.
b. Add a ListBox control to Form1.
c. Right-click ListBox1, and then click Properties.
d. In Properties window, set the value of the DataSource property to DataSet11, and then set the value of the DisplayMember property to Customers.CustomerID.
e. Add two TextBox controls to Form1.
10.On the View menu, click Solution Explorer.
11.In Solution Explorer, double-click DataSet1.xsd.
12.Right-click the Customers table, and then click Delete.
13.On the File menu, click Save All to save the project.
14.Double-click Form1.vb to open Form1. The error message that was mentioned in the "Symptoms" section of this article appears and all the controls that were added to Form1 before ListBox1 was added are removed.

Back to the top

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.addrange(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.addrange(vs.71).aspx)

Back to the top


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

Back to the top

Keywords: 
kbtshoot kberrmsg kbprb kbsystemdata kbschema kbwindowsforms kbtable kbstoredproc kbsqlclient kbdesigner kbdatabinding kbdatabase kbdataadapter kbctrl kbcontrol kbcollections KB816799

Back to the top

   

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please