movable user controls in runtime

  • Thread starter Thread starter marounb98
  • Start date Start date
M

marounb98

Guest
Hello, can anyone please tell me how can i move custom user controls to a panel by dragging them in runtime .

i have tried this but unfortunately the user control wont be placed at the exact location (mouse Position)

(for example if i drag a btn to the top of the Pg , it will be placed at the middle ,when i drop it )

Pg is the name of the panel which i want to drag into the user controls (1093X1428)

i am using a split container :-panel 1 contains pg

-panel 2 the user controls


Private Sub Btn_Up(sender As Object, e As MouseEventArgs) Handles Btn.MouseUp

Me.Cursor = Cursors.Default
Dim b As New animal
Dim Ml As Point = MousePosition
b.Tag = "My.Resources.bear"
b.bearPicture.Image = My.Resources.bear
b.bearPicture.Text = "bear" & nb_bear.ToString
b.bearPicture.ForeColor = Color.Black
nb_bearPicture= nb_bearPicture+ 1
Ml.Offset(-SplitContainer1.Panel2.Width - 50, -50)
b.Location = Ml

Pg.Controls.Add(b)

End Sub


thank you.

Continue reading...
 
Back
Top