标签:
//当有多个窗体时,对顶层的窗口进行操作,例如:我们开发具有录入功能的界面的时候,为了防止提交后的二次(重复)录入,希望点击提交按钮并提示成功后,界面的所有文本框能够自动清空
.NET Framework 类库
Form.ActiveMdiChild 属性
获取当前活动的多文档界面 (MDI) 子窗口。
命名空间:System.Windows.Forms
程序集:System.Windows.Forms(在 system.windows.forms.dll 中)
语法:public Form ActiveMdiChild { get; }
示例:
public void ClearAllChildFormText() { // Obtain a reference to the currently active MDI child form. Form tempChild = this.ActiveMdiChild; // Loop through all controls on the child form. for (int i = 0; i < tempChild.Controls.Count; i++) { // Determine if the current control on the child form is a TextBox. if (tempChild.Controls[i] is TextBox) { // Clear the contents of the control since it is a TextBox. tempChild.Controls[i].Text = ""; } } }
标签:
原文地址:http://www.cnblogs.com/lchangyu/p/5951573.html