c# - 修改 FlowLayoutPanel 中动态添加的元素

标签 c# winforms

如何修改 FlowLayoutPanel 中动态添加的元素?

我创建标签并将其添加到面板。

`for (int i=0; i<10; i++)
{
Label nlabel = new Label();
nlabel.text = "Label no."+i.toString();
nlabel.name = "label"+i.toString();
flowLayoutPanel1.Controls.Add(nlabel);.
}`  

创建和添加后我想引用元素“i”。 该面板没有方法 FlowLayoutPanel.getItem(int index) ;(

怎么做?

感谢回答。

最佳答案

就像所有控件一样,FlowLayoutPanel 有一个 Controls 集合属性,您可以按序号或名称对其进行索引。

关于c# - 修改 FlowLayoutPanel 中动态添加的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33962519/

相关文章:

c# - WinForms:如何防止文本框处理alt键并失去焦点?

c# - DataGridView 捕获用户行选择

c# - 如何确定 Entity Framework 对象是否已更改?

c# - 使用 Network Solutions 托管电子邮件的 System.Net 邮件设置

c# - 无法将 "void"隐式转换为 "bool"

c# - Membus 和简单注入(inject)器 - 通过接口(interface)自动连接命令处理程序

c# - 使用 C# 将 HTTP POST 发送到 Rails 3

c# - 检查 CSV 文件是否为空/避免抛出异常

c# - 关于如何记住.NET WinForm上以前的用户选择的想法

c# - 如何停止 Designer 为用户控件上的公共(public)属性生成代码?