QueryContinueDragEventHandler Temsilci
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
bir olayını Controlişleyecek QueryContinueDrag 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
Olayın kaynağı.
QueryContinueDragEventArgs Olay verilerini içeren bir.
Örnekler
Aşağıdaki örnekte, iki ListBox denetim arasında sürükle ve bırak işlemi gösterilmektedir. Örnek, sürükleme eylemi başlatıldığında yöntemini çağırır DoDragDrop . Fare olay sırasında MouseDown fare konumundan daha fazla SystemInformation.DragSize hareket ettiyse sürükleme eylemi 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.cur
var olduğu varsayılır. İşaretlenirse UseCustomCursorsCheck
CheckBox ö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ğ ListBox
için olay işleyicisinde değerlendirilirDragOver. Bırakma işleminin ListBox
gerçekleşeceği konum da olay sırasında DragOver
belirlenir. Bırakacak veriler bir String
değilse, DragEventArgs.Effect olarak ayarlanır DragDropEffects.None. Son olarak, bırakmanın durumu içinde DropLocationLabel
Labelgörüntülenir.
Sağ ListBox
için bırakacak veriler olay işleyicisinde DragDrop belirlenir ve String
değeri içinde ListBox
uygun 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ı, temsilciyi QueryContinueDragEventHandler olayla birlikte QueryContinueDrag kullanmayı 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 her gerçekleştiğinde, olay işleyici (siz temsilciyi kaldırmadığınız sürece) çağrılır. Temsilcileriyle olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.
Uzantı Metotları
GetMethodInfo(Delegate) |
Belirtilen temsilci tarafından temsil edilen yöntemi temsil eden bir nesnesi alır. |
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin