拆分容器错误

本文关键字:错误 拆分 | 更新日期: 2023-09-27 18:33:01

我有这个错误报告:

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 帖子。有什么想法吗?这个异常到底是关于什么的,如果我找到一些一般描述,我可能会找到修复它的方法,这是如何发生的?

拆分容器错误

在代码中的某个地方,您正在尝试删除 SplitContainer 控件的内部面板

像这样的东西重现了错误:

splitContainer1.Controls.RemoveAt(0);

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