0

我有这个错误报告:

Collection is read only.
at System.Windows.Forms.SplitContainer.SplitContainerTypedControlCollection.SetChildIndexInternal(Control child, Int32 newIndex)
at System.Windows.Forms.Control.ControlCollection.SetChildIndex(Control child, Int32 newIndex)
at System.Windows.Forms.Control.UpdateChildControlIndex(Control ctl)
at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.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)

我不知道它是什么,搜索只是给了我一篇没有解决方案的 msdn 帖子。有任何想法吗?这个异常到底是关于什么的,如果我找到一些一般性的描述,我可能会找到解决它的方法,这是如何发生的?

4

1 回答 1

1

在您的代码中的某处,您正试图删除 SplitContainer 控件的内部面板

这样的事情会重现错误:

splitContainer1.Controls.RemoveAt(0);

您必须在代码中搜索您尝试删除或移除子控件的位置。很容易来自递归方法。

于 2013-09-27T16:59:18.243 回答