ToolStripItem.DragEnter 이벤트

정의

사용자가 이 항목의 클라이언트 영역으로 항목을 끌 때 발생합니다.

public:
 event System::Windows::Forms::DragEventHandler ^ DragEnter;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.DragEventHandler DragEnter;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.DragEventHandler? DragEnter;
[<System.ComponentModel.Browsable(false)>]
member this.DragEnter : System.Windows.Forms.DragEventHandler 
Public Custom Event DragEnter As DragEventHandler 

이벤트 유형

특성

예제

다음 코드 예제에서는 변환 하는 방법에 설명 합니다 XY 속성을 클라이언트 Point합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripRenderer 클래스입니다.

// This method defines the DragOver event behavior. 
protected override void OnDragOver(DragEventArgs dea)
{
    base.OnDragOver(dea);

    // Get the ToolStripButton control 
    // at the given mouse position.
    Point p = new Point(dea.X, dea.Y);
    ToolStripButton item = this.GetItemAt(
        this.PointToClient(p)) as ToolStripButton;

    // If the ToolStripButton control is the empty cell,
    // indicate that the move operation is valid.
    if( item == this.emptyCellButton )
    {
        // Set the drag operation to indicate a valid move.
        dea.Effect = DragDropEffects.Move;
    }
}
' This method defines the DragOver event behavior. 
Protected Overrides Sub OnDragOver(dea As DragEventArgs)
   MyBase.OnDragOver(dea)
   
   ' Get the ToolStripButton control 
   ' at the given mouse position.
   Dim p As New Point(dea.X, dea.Y)
   Dim item As ToolStripButton = CType(Me.GetItemAt(Me.PointToClient(p)), ToolStripButton)
   
   
   ' If the ToolStripButton control is the empty cell,
   ' indicate that the move operation is valid.
     If item Is Me.emptyCellButton Then
         ' Set the drag operation to indicate a valid move.
         dea.Effect = DragDropEffects.Move
     End If
 End Sub

설명

DragEnter 사용자가 끌어서 놓기 작업 중에 마우스 커서를 항목 위로 처음 끌면 이벤트가 발생합니다.

다음 설명에서는 끌어서 놓기 작업과 관련된 이벤트가 발생하는 방법과 시기에 대해 설명합니다.

메서드는 DoDragDrop 현재 커서 위치 아래의 항목을 결정합니다. 그런 다음 항목이 유효한 삭제 대상인지 확인합니다.

항목이 유효한 놓기 대상인 GiveFeedback 경우 끌어서 놓기 효과가 지정된 상태에서 이벤트가 발생합니다. 끌어서 놓기 작업 결과 목록에 대한 자세한 내용은 DragDropEffects 열거형을 참조하십시오.

마우스 커서 위치, 키보드 상태 및 마우스 단추 상태의 변경 내용은 다음과 같은 방식으로 추적됩니다.

  • 사용자가 창의 외부로 이동하면 DragLeave 이벤트가 발생합니다.

  • 마우스가 다른 항목 DragEnter 에 들어가면 해당 컨트롤의 가 발생합니다.

  • 마우스가 이동하지만 동일한 항목 DragOver 내에 있으면 이벤트가 발생합니다.

키보드 또는 마우스 단추 상태가 QueryContinueDrag 변경되면 이벤트가 발생하고 끌기를 계속할지, 데이터를 삭제할지, 아니면 이벤트의 QueryContinueDragEventArgs속성 값 Action 에 따라 작업을 취소할지 결정합니다.

DragActionContinueDragOver 면 작업을 GiveFeedback 계속하기 위해 이벤트가 발생하고 적절한 시각적 피드백을 설정할 수 있도록 새 효과와 함께 이벤트가 발생합니다. 유효한 끌어서 놓기 작업 결과 목록에 대한 자세한 내용은 DragDropEffects 열거형을 참조하십시오.

DragOverGiveFeedback 이벤트는 마우스가 놓기 대상을 가로질러 이동할 때 다음과 같이 마우스 위치에 대한 최신 피드백을 받도록 페어링됩니다.

  • 경우 값 DragActionDrop놓기 결과 값이 소스로 반환은, 원본 애플리케이션은 원본 데이터에 대해 적절 한 작업을 수행할 수 있도록 예의 경우 데이터 잘라내기 작업이 이동 합니다.

  • DragActionCancelDragLeave 이 이면 이벤트가 발생합니다.

참고

DragEventArgsY 속성은 X 클라이언트 좌표가 아닌 화면 좌표에 있습니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상