mrty | | Tarih: 30.09.2007, 14:40 Mesaj konusu: ListBoxlar arasında Drag-Drop (C#) | |
| ListBoxlar arasında (ListBox 1den ListBox 2 ye ) sürükle bırak yöntemi
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
int sira;
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
Point nokta = new Point(e.X, e.Y);
sira = listBox1.IndexFromPoint(nokta);
if (e.Button == MouseButtons.Left)
listBox1.DoDragDrop(listBox1.Items[sira].ToString(), DragDropEffects.All);
}
private void listBox2_DragOver(object sender, DragEventArgs e)
{
if (e.KeyState == 1)
e.Effect = DragDropEffects.All;
}
private void listBox2_DragDrop(object sender, DragEventArgs e)
{
listBox2.Items.Add(listBox1.Items[sira]);
listBox1.Items.Remove(listBox1.Items[sira]);
// Kolay Gelsin
}
}
|
|