如何从flowlayout面板C#中删除特定控件? [英] How to remove particular control from flowlayout panel C# ?

查看:697
本文介绍了如何从flowlayout面板C#中删除特定控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为flowlayout面板添加了一些组合框行控件,

现在我想删除选定的组合行。



添加代码是

i have added some combobox rows controls to flowlayout panel ,
now i want to remove selected row of combobox .

add code is

this.Panel1.Controls.Add(combo1);

推荐答案

想法?这里可能需要什么想法?致电 Control.Controls.Remove

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection%28v=vs。 110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.remove(ⅴ = vs.110).aspx [ ^ ]。



请理解:此论坛适用于软件开发人员询问合格的问题,而不是帮助阅读文档对于那些不想或不想阅读它的人。



-SA
Ideas? What "ideas" could be needed here? Call Control.Controls.Remove.
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.remove(v=vs.110).aspx[^].

And please understand: this forum is for software developers asking qualified questions, not for helping reading documentation for people who cannot or don't want to read it.

—SA


那里从FlowLayoutPanel中删除的UserControls中没有被实际处理的众所周知的问题,导致最终的内存不足错误。



推荐的删除策略并且从FlowLayoutPanel处理UserControl是:
There are well-known problems with UserControls removed from a FlowLayoutPanel not being actually disposed of, resulting in, finally, out-of-memory errors.

The recommended strategy for removing and disposing UserControls from the FlowLayoutPanel is:
int yourIndex;

// get the Index value and assign it to 'yourIndex

Control toRemove = yourTableLayoutPanel.Controls[yourIndex];

yourTableLayoutPanel.Controls.Remove[i];

toRemove.Dipose();

如果你在FlowLayoutPanel中创建了很多破坏性的控件,我建议为了方便你保留一个字典<

If you are creating an destroying lots of Controls in the FlowLayoutPanel, I'd suggest that for convenience you keep a Dictionary<






参考:如何:在运行时添加或删除控件集合


这篇关于如何从flowlayout面板C#中删除特定控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆