using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Walter.K.Wang
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
listBox1.DoDragDrop(listBox1.SelectedItem.ToString(), DragDropEffects.Move);
}
private void listBox2_MouseDown(object sender, MouseEventArgs e)
{
string items = "";
for (int i = 0; i < listBox2.SelectedItems.Count; i++)
{
items += listBox2.SelectedItems[i].ToString();
}
listBox2.DoDragDrop(items, DragDropEffects.Move);
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
}
private void listBox2_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
}
private void listBox2_DragDrop(object sender, DragEventArgs e)
{
if (listBox2.Focused)
{
e.Effect = DragDropEffects.None;
}
else
{
listBox2.Items.Add(e.Data.GetData(DataFormats.Text));
listBox1.Items.Remove(listBox1.SelectedItem);
}
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
if (listBox1.Focused)
{
e.Effect = DragDropEffects.None;
}
else
{
listBox1.Items.Add(e.Data.GetData(DataFormats.Text));
listBox2.Items.Remove(listBox2.SelectedItem);
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Walter.K.Wang
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
listBox1.DoDragDrop(listBox1.SelectedItem.ToString(), DragDropEffects.Move);
}
private void listBox2_MouseDown(object sender, MouseEventArgs e)
{
string items = "";
for (int i = 0; i < listBox2.SelectedItems.Count; i++)
{
items += listBox2.SelectedItems[i].ToString();
}
listBox2.DoDragDrop(items, DragDropEffects.Move);
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
}
private void listBox2_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.AllowedEffect;
}
private void listBox2_DragDrop(object sender, DragEventArgs e)
{
if (listBox2.Focused)
{
e.Effect = DragDropEffects.None;
}
else
{
listBox2.Items.Add(e.Data.GetData(DataFormats.Text));
listBox1.Items.Remove(listBox1.SelectedItem);
}
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
if (listBox1.Focused)
{
e.Effect = DragDropEffects.None;
}
else
{
listBox1.Items.Add(e.Data.GetData(DataFormats.Text));
listBox2.Items.Remove(listBox2.SelectedItem);
}
}
}
}