首页 > Windows开发 > 详细

winform窗体中查找控件

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

     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窗体中查找控件

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!