foreach (Control c in groupBox1.Controls)
{
if (c is TextBox)
{
//这里写代码逻辑
}
}

遍历的时候,需要用Control遍历;

如果直接使用foreach(TextBox t in groupBox1.Controls)

并且groupbox上有Lable或其他非textbox控件的时候,会提示不能强制转换为textbox

所以,需要使用 is来判断,获取的控件是否为textbox

遍历GroupBox上的所有的textbox的更多相关文章

  1. asp.net中遍历界面上所有控件进行属性设置

    * 使用方法: *  前台页面调用方法,重置:    protected void Reset_Click(object sender, EventArgs e)        {           ...

  2. .Net遍历窗体上控件

    实现遍历窗体上的控件以及找出TextBox控件,代码如下: foreach( Control control in this.Controls ) { if( control is TextBox ) ...

  3. NX二次开发-NXOPEN_DimensionCollection遍历图纸上的所有标注尺寸

    NX11+VS2013 #include <NXOpen/Drawings_DrawingSheet.hxx> #include <NXOpen/Drawings_DrawingSh ...

  4. 遍历页面上所有TextBox,并赋值为String.Empty

    //不含母板页 foreach (System.Web.UI.Control txtobj in this.Page.Controls)   {     if (txtobj.GetType().Na ...

  5. expect结合ssh遍历线上机器

    有个需求,有个文件删除了,但是不确定线上机器还都存不存在 #!/home/work/.jumbo/bin/expect -f set timeout - set mac [lindex $argv ] ...

  6. Winform - 判断GroupBox控件中的TextBox文本框是不是为空

    foreach (Control item in this.groupBox2.Controls) { if (item is TextBox) { if (item.Text.Trim() == & ...

  7. 遍历页面上主从表中从table中的内容

    //如果在建VL的时候没有建访问器.从主表行拿到从表VO的行级不太好搞的 OAAdvancedTableBean innerTable = (OAAdvancedTableBean)webBean.f ...

  8. JEECMS-新闻内容中遍历批量上传的图片

    [#list content.pictures as p] <li value="${p_index+1}"> <img src="${p.imgPat ...

  9. ts 遍历Class上的属性和方法

    interface Type<T> extends Function { new (...args: any[]): T; } class Data { name = "ajan ...

随机推荐

  1. innodb next-key lock引发的死锁

    innodb的事务隔离级别是可重复读级别且innodb_locks_unsafe_for_binlog禁用,也就是说允许next-key lock CREATE TABLE `LockTest` (  ...

  2. 图片放大_css3

    .flash_little_img{position:relative;}.flash_little_img{width:500px;height:333px;border:none; margin: ...

  3. pip第三方模块

    在安装好pip的情况下,在cmd窗口调用命令:pip install package -i --trusted-host http://pypi.douban.com/simple(这是豆瓣的源)

  4. PAT 1070 Mooncake[一般]

    1070 Mooncake (25)(25 分) Mooncake is a Chinese bakery product traditionally eaten during the Mid-Aut ...

  5. 你应该知道的最好Webmail邮件客户端,

    1 . Kite Kite is an opensource replacement to Gmail. Kite is a webmail designed to look a lot like g ...

  6. Microsoft Interview第一轮

    上来随意交谈了一小会儿,开了点小玩笑,chat了一些关于他们recruter行程的话题,缓和了一下气氛. 进入正题,问了做的research的方向,我说是DLT,然后大概给他讲解了一下具体是什么, 跟 ...

  7. SQL工具类

    package com.ebizwindow.crm.utils; import java.util.List; import com.ebizwindow.crm.constants.SqlCons ...

  8. Dapper Extensions中修改Dialect

    如果是MySql数据库,则修改为:DapperExtensions.DapperExtensions.SqlDialect = new MySqlDialect(); DapperExtensions ...

  9. WPF学习笔记-用Expression Design制作矢量图然后导出为XAML

    WPF学习笔记-用Expression Design制作矢量图然后导出为XAML 第一次用Windows live writer写东西,感觉不错,哈哈~~ 1.在白纸上完全凭感觉,想象来画图难度很大, ...

  10. entity framework 新增,更新,事务

    protected void Button1_Click(object sender, EventArgs e) { yyEntities _db; _db = new yyEntities(); t ...