Form.ActiveForm 속성

정의

이 애플리케이션의 현재 활성 폼을 가져옵니다.

public:
 static property System::Windows::Forms::Form ^ ActiveForm { System::Windows::Forms::Form ^ get(); };
public static System.Windows.Forms.Form ActiveForm { get; }
public static System.Windows.Forms.Form? ActiveForm { get; }
member this.ActiveForm : System.Windows.Forms.Form
Public Shared ReadOnly Property ActiveForm As Form

속성 값

Form

현재 활성 폼을 나타내는 Form이거나 활성 폼이 없는 경우 null입니다.

예제

다음은 현재 폼을 가져오고 폼의 모든 컨트롤을 사용하지 않도록 설정하는 예제입니다. 이 예제에서는 폼의 컬렉션을 사용하여 Controls 폼의 각 컨트롤을 반복하고 컨트롤을 사용하지 않도록 설정합니다.

void DisableActiveFormControls()
{
   
   // Create an instance of a form and assign it the currently active form.
   Form^ currentForm = Form::ActiveForm;
   
   // Loop through all the controls on the active form.
   for ( int i = 0; i < currentForm->Controls->Count; i++ )
   {
      
      // Disable each control in the active form's control collection.
      currentForm->Controls[ i ]->Enabled = false;

   }
}
public void DisableActiveFormControls()
 {
    // Create an instance of a form and assign it the currently active form.
    Form currentForm = Form.ActiveForm;
    
    // Loop through all the controls on the active form.
    for (int i = 0; i < currentForm.Controls.Count; i++)
    {
       // Disable each control in the active form's control collection.
       currentForm.Controls[i].Enabled = false;
    }
 }
Public Sub DisableActiveFormControls()
    ' Create an instance of a form and assign it the currently active form.
    Dim currentForm As Form = Form.ActiveForm
    
    ' Loop through all the controls on the active form.
    Dim i As Integer
    For i = 0 To currentForm.Controls.Count - 1
        ' Disable each control in the active form's control collection.
        currentForm.Controls(i).Enabled = False
    Next i
End Sub

설명

이 메서드를 사용 하 여 폼 또는 해당 컨트롤에 작업을 수행 하려면 현재 활성 폼에 대 한 참조를 가져올 수 있습니다.

애플리케이션은 (MDI) 다중 문서 인터페이스 애플리케이션을 사용 하 여는 ActiveMdiChild 속성을 현재 활성 상태인 MDI 자식 폼을 가져옵니다.

적용 대상

추가 정보