拖放事件在Windows 7或旧操作系统上正常工作。 但是不适用于Windows 8。 怎么解决?
private void listBox1_DragEnter(objectsender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void listBox1_MouseDown(objectsender, MouseEventArgs e)
{
Point sonnokta = new Point(e.X,e.Y);
int item_index = listBox1.IndexFromPoint(sonnokta);
if(e.Button == MouseButtons.Left)
{
listBox1.DoDragDrop(listBox1.Items[item_index],DragDropEffects.All);
}
}
private void listBox2_DragOver(objectsender, DragEventArgs e)
{
if(e.KeyState == 1)
{
e.Effect = DragDropEffects.All;
}
}
private void listBox2_DragDrop(objectsender, DragEventArgs e)
{
listBox2.Items.Add(e.Data.GetData(DataFormats.Text));
}