Well, the easiest way would be to retain an explicit reference to the buttons you're adding. Otherwise you could add a tag to distinguish them (to be robust against i18n issues). E.g. you can set the tag of "button2" to "button2" and then you can use:

foreach(Control ctl in flp.Controls){if("button2".Equals(ctl.Tag)){
ctl.BackColor=Color.Red;}

}

I am assuming your problem is to find the actual button again and not setting the background color. You could likewise check for the control being a button and its text being "button2" but if the text can change depending on the UI language that's probably not a good idea.

ETA: Totally forgot that you can use the control's Name property for this as well.

If you just want to change the background color of the button in a response to an event from the button you can just use the sender argument of the event handler, though.

//////

You can try Control.ControlCollection.Find.

flowLayoutPanel1.Controls.Add(newButton(){Text="button 1",Name="btn1"});
Button btn1 = flowLayoutPanel1.Controls.Find("btn1",true).FirstOrDefault()asButton;
btn1.Text="found!";

How to change the property of a control from a flowlayoutpanel?的更多相关文章

  1. How to change Form & Property & Report font for current User [AX2012]

    对于我们开发人员来说,系统默认的字体,本人实在不喜欢,尤其是属性字体[太小,太细,根本看不清],每次做一个新项目[AX2012]第一件事就是更改字体. 由于AX2012没有像AX2009那样,可以工具 ...

  2. List<> of struct with property. Cannot change value of property. why?

    这个返回如下错误:"Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.th ...

  3. Overview of Form Control Types [AX 2012]

    Overview of Form Control Types [AX 2012] Other Versions 0 out of 1 rated this helpful - Rate this to ...

  4. A Complete ActiveX Web Control Tutorial

    A Complete ActiveX Web Control Tutorial From: https://www.codeproject.com/Articles/14533/A-Complete- ...

  5. Writing a Reusable Custom Control in WPF

    In my previous post, I have already defined how you can inherit from an existing control and define ...

  6. Splitter Control for Dialog

    原文链接地址:https://www.codeproject.com/Articles/595602/Splitter-Control-for-Dialog Introduction Yes, tha ...

  7. Shape Control for .NET

    Shape Control for .NET Yang Kok Wah, 23 Mar 2017 CPOL    4.83 (155 votes)   Rate this: vote 1vote 2v ...

  8. How to: Change the Format Used for the FullAddress and FullName Properties 如何:更改用于FullAddress和FullName属性的格式

    There are FullAddress and FullName properties in the Address and Person business classes that are su ...

  9. WPF整理-Style

    "Consistency in a user interface is an important trait; there are many facets of consistency,   ...

随机推荐

  1. Windows下Wamp装不上Memcache扩展

    windows下wamp装不上memcache扩展2015.03.20 No Comments 1,243 views用的是WAMP集成包,PHP版本5.5.12http://windows.php. ...

  2. leetcode problem 37 -- Sudoku Solver

    解决数独 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated ...

  3. platform平台设备驱动简化示例代码

    driver.c: #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h& ...

  4. Java学习-数组

    1.数组的是Object的直接子类,它属于“第一类对象”,但是它又与普通的java对象存在很大的不同,类名为:[I 一维数组:[I 二维数组:[[I 三维数组:[[[I 2.[代表了数组的维度,一个[ ...

  5. Oracle分析函数之FIRST_VALUE和LAST_VALUE

    FIRST_VALUE 返回组中数据窗口的第一个值 FIRST_VALUE ( [scalar_expression )OVER ( [ partition_by_clause ] order_by_ ...

  6. 4.MVC框架开发(母版页的应用、按钮导致的Action处理、从界面向控制器传数据和HtmlHelper控件的实现(注册的实现))

    1.在视图里如何引入母版页 1)在视图里母版页都是放在View目录下面的Shared文件夹下面 2)母版页里的RenderBody()类似于ASP.NET里面的ContentPalceHolder占位 ...

  7. C# zip/unzip with ICSharpCode.SharpZipLib

    download ICSharpCode and add reference using System; using System.Collections.Generic; using System. ...

  8. linux下定时发送邮件

    at命令可以在某个时间运行某个程序,而mail可以以命令行的方式把存于一个文本中的邮件正文发送抄送出去. 具体用法:  1. 把email正文准备好,比如写在email.txt里  2. 然后写一个脚 ...

  9. 按行N等分某个文件

    # --*-- coding:utf-8 --*--import randomimport math def fanhui():    into = random.randint(1, 10)    ...

  10. 使用flask的时候遇到的问题及其解答

    在网上看到了mircoblog的这个web程序,用flask框架写的,自己就在windows的环境下实现了下. 1.这个博客系统用到了一个flask插件叫flask_Login 里面涉及到编码解码的问 ...