查找名称控件的Windows窗体控件 [英] Find control by name from Windows Forms controls

查看:166
本文介绍了查找名称控件的Windows窗体控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的文本框名称的列表,我想按名称查找控制。这怎么可能?

I have a list of my textbox names, and I want to find a control by name. How is it possible?

推荐答案

使用<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.find%28VS.80%29.aspx">Control.ControlCollection.Find.

TextBox tbx = this.Controls.Find("textBox1", true).FirstOrDefault() as TextBox;
tbx.Text = "found!";

编辑提问者:

EDIT for asker:

Control[] tbxs = this.Controls.Find(txtbox_and_message[0,0], true);
if (tbxs != null && tbxs.Length > 0)
{
    tbxs[0].Text = "Found!";
}

这篇关于查找名称控件的Windows窗体控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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