本文介绍了清除从FlowLayoutPanel的不是调用析构函数控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果我失去了一些东西很明显,但我想从一个FlowLayoutPanel中清除控件(一系列用户控件) - (panelName).Controls.Clear();不幸的是这似乎并没有被调用析构函数面板上的对象 - 用户对象在任务管理器栏只是不断上升和上升,直到达到10,000抛出excecption

Sorry if I'm missing something obvious, but I'm trying to clear the controls (a series of user controls) from a FlowLayoutPanel - (panelName).Controls.Clear();. Unfortunately this doesn't seem to be calling the destructors for the objects on the panel - the User Objects column in the task manager just keeps going up and up, until it hits 10,000 and throws an excecption.

有谁知道我在这里失踪了什么?

Does anyone know what I'm missing here?

推荐答案

不是一个解决办法,但有解决方法 - 对象似乎被这个破坏(粗糙,从内存中)code:

Not a solution, but a workaround - the objects do seem to be destroyed by this (rough, from memory) code:

while(FlowLayoutPanel.Controls.Count > 0)
     FlowLayoutPanel.Controls.Remove(0);

这篇关于清除从FlowLayoutPanel的不是调用析构函数控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:30