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 DragDropEffects satu nilai.
Contoh
Contoh berikut menunjukkan operasi seret dan letakkan di antara dua ListBox kontrol. Contoh memanggil DoDragDrop metode saat tindakan seret dimulai. Tindakan seret dimulai jika mouse telah memindahkan lebih dari SystemInformation.DragSize dari lokasi mouse selama MouseDown peristiwa. Metode IndexFromPoint ini digunakan untuk menentukan indeks item yang akan diseret selama MouseDown
peristiwa.
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 GiveFeedback aktivitas.
Status keyboard dievaluasi di DragOver penanganan aktivitas untuk sebelah kanan ListBox
, untuk menentukan operasi seret berdasarkan status tombol SHIFT, CTRL, ALT, atau CTRL+ALT. Lokasi di ListBox
mana 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 hak ListBox
ditentukan dalam DragDrop penanganan aktivitas dan String
nilai ditambahkan di tempat yang sesuai di ListBox
. Jika operasi seret bergerak di luar batas formulir, maka operasi seret dan letakkan dibatalkan di QueryContinueDrag penanganan aktivitas.
Kutipan kode ini menunjukkan menggunakan GiveFeedbackEventArgs kelas . DoDragDrop Lihat metode 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
Berlaku untuk
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk