Изменить иконку, используемую при перетаскивании мышью - C#
Формулировка задачи:
Всем здравствуйте.
Речь о DragAndDrop.
Находясь над label1 при нажатии и удержании левой кнопки мыши курсор превращается в перечёркнутый круг. Как сделать так чтобы изображение курсора при этом поменялось на пользовательское.
private void label1_MouseDown(object sender, MouseEventArgs e)
{
//p = e.Location;
if (e.Button == MouseButtons.Left)
DoDragDrop(sender, DragDropEffects.All);
}Решение задачи: «Изменить иконку, используемую при перетаскивании мышью»
textual
Листинг программы
namespace gragdrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
}
private void picSource_MouseDown(object sender, MouseEventArgs e)
{
picSource.DoDragDrop(sender, DragDropEffects.None);
}
private void picSource_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
// Sets the custom cursor based upon the effect. (пользовательский курсор)
e.UseDefaultCursors = false;
if ((e.Effect & DragDropEffects.Move) == DragDropEffects.Move)
Cursor.Current = Cursors.Default;
else
Cursor.Current = new Cursor("1.ico");
}
}
}