winform窗体中查找控件
时间:2014-07-05 20:56:38
收藏:0
阅读:433
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;
}
评论(0)