다음을 통해 공유


Form.ActiveForm 속성

이 응용 프로그램의 현재 활성 폼을 가져옵니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Shared ReadOnly Property ActiveForm As Form
‘사용 방법
Dim value As Form

value = Form.ActiveForm
public static Form ActiveForm { get; }
public:
static property Form^ ActiveForm {
    Form^ get ();
}
/** @property */
public static Form get_ActiveForm ()
public static function get ActiveForm () : Form

속성 값

현재 활성 폼을 나타내는 Form이거나 활성 폼이 없는 경우 Null 참조(Visual Basic의 경우 Nothing)입니다.

설명

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

응용 프로그램이 MDI(다중 문서 인터페이스) 응용 프로그램인 경우 ActiveMdiChild 속성을 사용하여 현재 활성 상태인 MDI 자식 폼을 얻습니다.

예제

다음 코드 예제에서는 활성 폼을 가져온 다음 해당 폼의 모든 컨트롤을 비활성화합니다. 이 예제에서는 폼의 Controls 컬렉션을 사용하여 해당 폼의 각 컨트롤 전체를 반복하여 비활성화합니다.

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 'DisableActiveFormControls
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;
    }
 }
    
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.get_ActiveForm();

    // Loop through all the controls on the active form.
    for (int i = 0; i < currentForm.get_Controls().get_Count(); i++) {
        // Disable each control in the active form's control collection.
        currentForm.get_Controls().get_Item(i).set_Enabled(false);
    }
} //DisableActiveFormControls

.NET Framework 보안

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Form 클래스
Form 멤버
System.Windows.Forms 네임스페이스
ActiveMdiChild