GiveFeedbackEventArgs.Effect Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan umpan balik operasi seret dan letakkan yang ditampilkan.
public:
property System::Windows::Forms::DragDropEffects Effect { System::Windows::Forms::DragDropEffects get(); };
public System.Windows.Forms.DragDropEffects Effect { get; }
member this.Effect : System.Windows.Forms.DragDropEffects
Public ReadOnly Property Effect As DragDropEffects
Nilai Properti
Salah satu nilai DragDropEffects.
Contoh
Contoh berikut menunjukkan operasi seret dan letakkan antara dua kontrol ListBox. Contoh memanggil metode DoDragDrop saat tindakan seret dimulai. Tindakan seret dimulai jika mouse telah memindahkan lebih dari SystemInformation.DragSize dari lokasi mouse selama peristiwa MouseDown. Metode IndexFromPoint digunakan untuk menentukan indeks item yang akan diseret selama peristiwa MouseDown
.
Contoh ini juga menunjukkan penggunaan kursor kustom untuk operasi seret dan letakkan. Contoh mengasumsikan bahwa dua file kursor, 3dwarro.cur
dan 3dwno.cur
, ada di direktori aplikasi, untuk kursor seret dan tanpa jatuhkan kustom. Kursor kustom akan digunakan jika UseCustomCursorsCheck
CheckBox dicentang. Kursor kustom diatur dalam penanganan aktivitas GiveFeedback.
Status keyboard dievaluasi dalam penanganan aktivitas DragOver untuk ListBox
kanan , untuk menentukan operasi seret apa yang akan didasarkan pada status tombol SHIFT, CTRL, ALT, atau CTRL+ALT. Lokasi di ListBox
tempat penurunan akan terjadi juga ditentukan selama peristiwa DragOver
. Jika data yang akan dihilangkan bukan String
, maka DragEventArgs.Effect diatur ke DragDropEffects.None. Akhirnya, status penurunan ditampilkan di DropLocationLabel
Label.
Data yang akan dihilangkan untuk ListBox
yang tepat ditentukan dalam penanganan aktivitas DragDrop dan nilai String
ditambahkan di tempat yang sesuai di ListBox
. Jika operasi seret bergerak di luar batas formulir, maka operasi seret dan letakkan dibatalkan di penanganan aktivitas QueryContinueDrag.
Kutipan kode ini menunjukkan menggunakan kelas GiveFeedbackEventArgs. Lihat metode DoDragDrop untuk contoh kode lengkap.
void ListDragSource_GiveFeedback( Object^ /*sender*/, System::Windows::Forms::GiveFeedbackEventArgs^ e )
{
// Use custom cursors if the check box is checked.
if ( UseCustomCursorsCheck->Checked )
{
// Sets the custom cursor based upon the effect.
e->UseDefaultCursors = false;
if ( (e->Effect & DragDropEffects::Move) == DragDropEffects::Move )
::Cursor::Current = MyNormalCursor;
else
::Cursor::Current = MyNoDropCursor;
}
}
private void ListDragSource_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
// Use custom cursors if the check box is checked.
if (UseCustomCursorsCheck.Checked)
{
// Sets the custom cursor based upon the effect.
e.UseDefaultCursors = false;
if ((e.Effect & DragDropEffects.Move) == DragDropEffects.Move)
Cursor.Current = MyNormalCursor;
else
Cursor.Current = MyNoDropCursor;
}
}
Private Sub ListDragSource_GiveFeedback(ByVal sender As Object, ByVal e As GiveFeedbackEventArgs) Handles ListDragSource.GiveFeedback
' Use custom cursors if the check box is checked.
If (UseCustomCursorsCheck.Checked) Then
' Set the custom cursor based upon the effect.
e.UseDefaultCursors = False
If ((e.Effect And DragDropEffects.Move) = DragDropEffects.Move) Then
Cursor.Current = MyNormalCursor
Else
Cursor.Current = MyNoDropCursor
End If
End If
End Sub