码迷,mamicode.com
首页 > Windows程序 > 详细

winform窗体中查找控件

时间:2014-07-05 20:56:38      阅读:433      评论:0      收藏:0      [点我收藏+]

标签:winform   for   io   amp   app   text   

     private RichTextBox FindControl()
        {

            RichTextBox ret = null;
            try
            {
                Control[] controls = Application.OpenForms["MainForm"].Controls.Find("txtContent", false);
                if (controls != null && controls.Length > 0)
                {
                    foreach (Control cn in controls)
                    {
                        if (cn is RichTextBox)
                        {
                            ret = (cn as RichTextBox);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return ret;
        }

winform窗体中查找控件,布布扣,bubuko.com

winform窗体中查找控件

标签:winform   for   io   amp   app   text   

原文地址:http://www.cnblogs.com/xiaogongzhu/p/3826309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!