Private Sub Button1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
Dim btn As Button = CType(sender, Button)
btn.DoDragDrop(sender, DragDropEffects.Move)
End Sub
Private Sub Panel1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop, Panel2.DragDrop
Dim btn As Button = e.Data.GetData("Button")
e.Effect = DragDropEffects.Move
btn.Parent = sender
End Sub
DragDrop на VB
подскажите плз, как сделать DragDrop между 2-мя объектами, т.е. есть 2 панели на одной их них кнопка, надо эту кнопку мышкой таскать с одной на другую
Код:
в обработчике события Panel1_DragDrop из DragEventArgs никак не могу вытащить Button отладчик пишет btn = Nothing
ЗЫ: на C# такой код работал:
Код:
private void button1_MouseDown(object sender, MouseEventArgs e)
{
Button btn = sender as Button;
btn.DoDragDrop(sender, DragDropEffects.All);
}
private void panel1_DragDrop_1(object sender, DragEventArgs e)
{
Button btn = e.Data.GetData(typeof(Button)) as Button;
e.Effect = DragDropEffects.All;
btn.Parent = sender as Panel;
}
private void panel1_DragOver_1(object sender, DragEventArgs e)
{
Button btn = e.Data.GetData(typeof(Button)) as Button;
e.Effect = DragDropEffects.All;
btn.Parent = sender as Panel;
}
{
Button btn = sender as Button;
btn.DoDragDrop(sender, DragDropEffects.All);
}
private void panel1_DragDrop_1(object sender, DragEventArgs e)
{
Button btn = e.Data.GetData(typeof(Button)) as Button;
e.Effect = DragDropEffects.All;
btn.Parent = sender as Panel;
}
private void panel1_DragOver_1(object sender, DragEventArgs e)
{
Button btn = e.Data.GetData(typeof(Button)) as Button;
e.Effect = DragDropEffects.All;
btn.Parent = sender as Panel;
}