Form.ActiveMdiChild プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
このメソッドを使用して、MDI アプリケーションで、開いている MDI 子フォームがあるかどうかを確認できます。また、このメソッドを使用すると、MDI 親フォームまたはアプリケーションに表示されている別のフォームから、MDI 子ウィンドウに対して操作を実行することもできます。
現在アクティブなフォームが MDI 子フォームでない場合は、ActiveForm プロパティを使用して、現在アクティブなフォームへの参照を取得できます。
アクティブな MDI 子フォームへの参照を取得して、フォーム上のすべての TextBox コントロールをループ処理し、それぞれの Text プロパティをリセットするコード例を次に示します。この例では、MDI 親フォームが作成済みであること、およびこのメソッドがその MDI 親フォームから呼び出されていることを前提にしています。
Public Sub ClearAllChildFormText() ' Obtain a reference to the currently active MDI child form. Dim tempChild As Form = Me.ActiveMdiChild ' Loop through all controls on the child form. Dim i As Integer For i = 0 To tempChild.Controls.Count - 1 ' Determine if the current control on the child form is a TextBox. If TypeOf tempChild.Controls(i) Is TextBox Then ' Clear the contents of the control since it is a TextBox. tempChild.Controls(i).Text = "" End If Next i End Sub 'ClearAllChildFormText
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 = ""; } } }
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 ( dynamic_cast<TextBox^>(tempChild->Controls[ i ]) ) { // Clear the contents of the control since it is a TextBox. tempChild->Controls[ i ]->Text = ""; } } }
public void ClearAllChildFormText() { // Obtain a reference to the currently active MDI child form. Form tempChild = this.get_ActiveMdiChild(); // Loop through all controls on the child form. for (int i = 0; i < tempChild.get_Controls().get_Count(); i++) { // Determine if the current control on the child form is a // TextBox. if (tempChild.get_Controls().get_Item(i) instanceof TextBox) { // Clear the contents of the control since it is a TextBox. tempChild.get_Controls().get_Item(i).set_Text(""); } } } //ClearAllChildFormText
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Weblioに収録されているすべての辞書からForm.ActiveMdiChild プロパティを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からForm.ActiveMdiChild プロパティを検索
- Form.ActiveMdiChild プロパティのページへのリンク