QueryContinueDragEventHandler Temsilci

Tanım

bir olayını QueryContinueDragişleyecek Control yöntemi temsil eder.

public delegate void QueryContinueDragEventHandler(System::Object ^ sender, QueryContinueDragEventArgs ^ e);
public delegate void QueryContinueDragEventHandler(object sender, QueryContinueDragEventArgs e);
public delegate void QueryContinueDragEventHandler(object? sender, QueryContinueDragEventArgs e);
type QueryContinueDragEventHandler = delegate of obj * QueryContinueDragEventArgs -> unit
Public Delegate Sub QueryContinueDragEventHandler(sender As Object, e As QueryContinueDragEventArgs)

Parametreler

sender
Object

Bir olayın kaynağı.

Örnekler

Aşağıdaki örnekte, iki ListBox denetim arasındaki sürükle ve bırak işlemi gösterilmektedir. Örnek, sürükleme eylemi başladığında yöntemini çağırır DoDragDrop . Sürükleme eylemi, fare olay sırasında SystemInformation.DragSize fare konumundan daha fazla MouseDown hareket ettiyse başlar. IndexFromPoint yöntemi, olay sırasında sürüklenecek öğenin dizinini MouseDown belirlemek için kullanılır.

Örnekte, sürükle ve bırak işlemi için özel imleçlerin kullanılması da gösterilmektedir. Örnekte, 3dwarro.cur özel sürükleme ve bırakmama imleçleri için uygulama dizininde sırasıyla iki imleç dosyası ve 3dwno.curvar olduğu varsayılır. İşaretlenirse UseCustomCursorsCheckCheckBox özel imleçler kullanılır. Özel imleçler olay işleyicisinde GiveFeedback ayarlanır.

Klavye durumu, shift, CTRL, ALT veya CTRL+ALT tuşlarının durumuna bağlı olarak sürükleme işleminin ne olacağını belirlemek için sağ DragOveriçin olay işleyicisinde değerlendirilirListBox. Bırakmanın ListBox gerçekleşeceği konum da olay sırasında DragOver belirlenir. Bırakacak veriler bir Stringdeğilse, DragEventArgs.Effect olarak ayarlanır DragDropEffects.None. Son olarak, bırakmanın durumu içinde DropLocationLabelLabelgörüntülenir.

Sağ ListBox için bırakacak veriler olay işleyicisinde DragDrop belirlenir ve String değeri içinde ListBoxuygun yere eklenir. Sürükleme işlemi formun sınırlarının dışına taşınırsa, olay işleyicisinde QueryContinueDrag sürükle ve bırak işlemi iptal edilir.

Bu kod alıntısı, temsilcinin QueryContinueDragEventHandler olayla birlikte QueryContinueDrag kullanılmasını gösterir. DoDragDrop Tam kod örneği için yöntemine bakın.

void ListDragSource_QueryContinueDrag( Object^ sender, System::Windows::Forms::QueryContinueDragEventArgs^ e )
{
   // Cancel the drag if the mouse moves off the form.
   ListBox^ lb = dynamic_cast<ListBox^>(sender);
   if ( lb != nullptr )
   {
      Form^ f = lb->FindForm();

      // Cancel the drag if the mouse moves off the form. The screenOffset
      // takes into account any desktop bands that may be at the top or left
      // side of the screen.
      if ( ((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) || ((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) || ((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) || ((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom) )
      {
         e->Action = DragAction::Cancel;
      }
   }
}
private void ListDragSource_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
    // Cancel the drag if the mouse moves off the form.
    ListBox lb = sender as ListBox;

    if (lb != null)
    {
        Form f = lb.FindForm();

        // Cancel the drag if the mouse moves off the form. The screenOffset
        // takes into account any desktop bands that may be at the top or left
        // side of the screen.
        if (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) ||
            ((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) ||
            ((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) ||
            ((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom))
        {
            e.Action = DragAction.Cancel;
        }
    }
}
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
    ' Cancel the drag if the mouse moves off the form.
    Dim lb As ListBox = CType(sender, ListBox)

    If (lb IsNot Nothing) Then

        Dim f As Form = lb.FindForm()

        ' Cancel the drag if the mouse moves off the form. The screenOffset
        ' takes into account any desktop bands that may be at the top or left
        ' side of the screen.
        If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or
            ((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or
            ((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or
            ((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then

            e.Action = DragAction.Cancel
        End If
    End If
End Sub

Açıklamalar

Bir QueryContinueDragEventHandler temsilci oluşturduğunuzda, olayı işleyecek yöntemi tanımlarsınız. Olayı olay işleyicinizle ilişkilendirmek için, olaya temsilcinin bir örneğini ekleyin. Olay işleyicisi, temsilciyi kaldırmadığınız sürece olay gerçekleştiğinde çağrılır. Temsilcileriyle olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

Uzantı Metotları

Name Description
GetMethodInfo(Delegate)

Belirtilen temsilci tarafından temsil edilen yöntemi temsil eden bir nesnesi alır.

Şunlara uygulanır

Ayrıca bkz.