DragAction Sabit listesi
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.
Sürükle ve bırak işleminin nasıl ve nasıl devam etmesi gerektiğini belirtir.
public enum class DragAction
[System.Runtime.InteropServices.ComVisible(true)]
public enum DragAction
public enum DragAction
[<System.Runtime.InteropServices.ComVisible(true)>]
type DragAction =
type DragAction =
Public Enum DragAction
- Devralma
- Öznitelikler
Alanlar
Cancel | 2 | İşlem bırakma iletisi olmadan iptal edilir. |
Continue | 0 | İşlem devam edecektir. |
Drop | 1 | İşlem bir bırakma ile durdurulacaktır. |
Ö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ı numaralandırmanın DragAction 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
Bu numaralandırma tarafından QueryContinueDragEventArgskullanılır.
Şunlara uygulanır
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