2013-09-27 41 views
0

我有這個錯誤報告:SplitContainer的錯誤

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後無解。有任何想法嗎?這個例外是關於什麼的,如果我找到一些可以發生的一般性描述,我可能會找到解決它的方法?

在你的代碼
+0

顯示您的代碼? –

+0

這是錯誤報告。代碼有超過10,000行,這不會導致任何特定的部分。 所以問題是沒有人知道爲什麼這可能會發生? –

+1

該錯誤表示您正嘗試分配或從不允許進行此類操作的集合中刪除項目。它可能是一個'IEnumberable'或類似的只讀接口。 – Kami

回答

1

某處,你正在試圖刪除內部面板的SplitContainer的控制

像這樣的事情重現錯誤:

splitContainer1.Controls.RemoveAt(0); 

你必須在你的代碼來搜索你在哪裏試圖刪除或刪除子控件。很容易從遞歸方法。

+0

我在FlowContainer的一個容器中有FlowLayoutPanel。它有一些刪除其控制。但它不應該算,對吧?我會仔細檢查,但SplitContainer本身沒有任何刪除它的第一個孩子的控制... –

+0

@IvanIčinSplitContainer有一個控件屬性,隱藏着來自設計器和代碼的屬性,但它在那裏。你將不得不張貼導致錯誤的代碼來幫助我們。 – LarsTech

+0

我知道,我只是說沒有splitContainer.Controls.Remove ...也沒有splitContainer.Panel1.Controls.Remove。也不splitContainer.Panel2.Controls.Remove。 –