Form.Activate Form.Activate Form.Activate Form.Activate Method

정의

폼을 활성화하고 포커스를 제공합니다.Activates the form and gives it focus.

public:
 void Activate();
public void Activate ();
member this.Activate : unit -> unit
Public Sub Activate ()

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 SetDesktopLocation, LoadActivate 멤버입니다.The following code example demonstrates how to use the SetDesktopLocation, Load and Activate members. 예제를 실행 하려면 이라는 폼에 다음 코드를 붙여 넣습니다 Form1 이라는 단추가 포함 된 Button1 두 개의 Label 컨트롤 이라는 Label1Label2합니다.To run the example, paste the following code in a form called Form1 containing a button called Button1 and two Label controls called Label1 and Label2.

static int x = 200;
static int y = 200;
void Button1_Click( System::Object^ sender, System::EventArgs^ e )
{
   
   // Create a new Form1 and set its Visible property to true.
   Form1^ form2 = gcnew Form1;
   form2->Visible = true;
   
   // Set the new form's desktop location so it  
   // appears below and to the right of the current form.
   form2->SetDesktopLocation( x, y );
   x += 30;
   y += 30;
   
   // Keep the current form active by calling the Activate
   // method.
   this->Activate();
   this->Button1->Enabled = false;
}


// Updates the label text to reflect the current values of x 
// and y, which was were incremented in the Button1 control's 
// click event.
void Form1_Activated( Object^ sender, System::EventArgs^ e )
{
   Label1->Text = String::Format( "x: {0} y: {1}", x, y );
   Label2->Text = String::Format( "Number of forms currently open: {0}", count );
}

static int count = 0;
void Form1_Closed( Object^ sender, System::EventArgs^ e )
{
   count -= 1;
}

void Form1_Load( Object^ sender, System::EventArgs^ e )
{
   count += 1;
}
static int x = 200;
static int y = 200;

private void Button1_Click(System.Object sender, 
	System.EventArgs e)
{
	// Create a new Form1 and set its Visible property to true.
	Form1 form2 = new Form1();
	form2.Visible = true;

	// Set the new form's desktop location so it  
	// appears below and to the right of the current form.
	form2.SetDesktopLocation(x, y);
	x += 30;
	y += 30;

	// Keep the current form active by calling the Activate
	// method.
	this.Activate();
	this.Button1.Enabled = false;
}



// Updates the label text to reflect the current values of x 
// and y, which was were incremented in the Button1 control's 
// click event.
private void Form1_Activated(object sender, System.EventArgs e)
{
	Label1.Text = "x: "+x+" y: "+y;
	Label2.Text = "Number of forms currently open: "+count;
}

static int count = 0;

private void Form1_Closed(object sender, System.EventArgs e)
{
	count -= 1;
}

private void Form1_Load(object sender, System.EventArgs e)
{
	count += 1;
}
Shared x As Integer = 200
Shared y As Integer = 200

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    ' Create a new Form1 and set its Visible property to true.
    Dim form2 As New Form1
    form2.Visible = True

    ' Set the new form's desktop location so it appears below and 
    ' to the right of the current form.
    form2.SetDesktopLocation(x, y)
    x += 30
    y += 30

    ' Keep the current form active by calling the Activate method.
    Me.Activate()
    Me.Button1.Enabled = False
End Sub



' Updates the label text to reflect the current values of x and y, 
' which was were incremented in the Button1 control's click event.
Private Sub Form1_Activated(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Activated
    Label1.Text = "x: " & x & " y: " & y
    Label2.Text = "Number of forms currently open: " & count
End Sub

Shared count As Integer = 0

Private Sub Form1_Closed(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Closed
    count -= 1
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    count += 1
End Sub

설명

폼을 활성화 하 앞으로 보냅니다 활성 애플리케이션 되었거나 활성 애플리케이션이 없는 경우 창 캡션을 깜박입니다.Activating a form brings it to the front if this is the active application, or it flashes the window caption if this is not the active application. 형식 매개 변수가 적용이이 메서드에 대 한 표시 되어야 합니다.The form must be visible for this method to have any effect. 애플리케이션에서 활성 폼을 확인 하려면 사용 합니다 ActiveForm 속성 또는 ActiveMdiChild 양식은 다중 문서 MDI (인터페이스) 애플리케이션의 경우 속성입니다.To determine the active form in an application, use the ActiveForm property or the ActiveMdiChild property if your forms are in a Multiple-document interface (MDI) application.

보안

UIPermission
포커스를 변경 합니다.for changing focus. 연관된 열거형: AllWindowsAssociated enumeration: AllWindows.

적용 대상

추가 정보