469,573 Members | 1,695 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Drag and Drop

2
hello, i have an urgent case,
i wanna know how to drag and drop panels created dynamically inside a big panel??

here's below the code i make but it didn't work :
plz if anyone can help me ...


Expand|Select|Wrap|Line Numbers
  1.   Private WithEvents DynamicPanel As Panel
  2.     Private WithEvents user As UserCtrl
  3.     Private index As Integer
  4.  
  5.     Private Sub ToolBtn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolBtn1.Click
  6.  
  7.         Dim DynamicSplitter As New Splitter
  8.  
  9.         Me.DynamicPanel = New Panel
  10.         Me.DynamicPanel.Dock = DockStyle.Left
  11.         Me.DynamicPanel.AllowDrop = True
  12.         Me.DynamicPanel.BackColor = Color.White
  13.         DynamicSplitter.Dock = DockStyle.Right
  14.         DynamicSplitter.BackColor = Color.DarkGray
  15.         Me.DynamicPanel.Controls.Add(DynamicSplitter)
  16.  
  17.         user = New UserCtrl
  18.         user.Location = New Point(0, 10)
  19.         user.BackColor = Color.Beige
  20.         Me.DynamicPanel.Controls.Add(user)
  21.         Me.Panel1.Controls.Add(DynamicPanel)
  22.  
  23.         AddHandler Me.DynamicPanel.MouseDown, AddressOf DynamicPanel_MouseDown
  24.  
  25.         AddHandler Me.DynamicPanel.DragEnter, AddressOf DynamicPanel_DragEnter
  26.         AddHandler Me.DynamicPanel.DragDrop, AddressOf DynamicPanel_DragDrop
  27.  
  28.     End Sub
  29.  
  30.     Private Sub DynamicPanel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DynamicPanel.MouseDown
  31.  
  32.         If e.Button = Windows.Forms.MouseButtons.Left Then
  33.             Me.DynamicPanel.DoDragDrop(Me.DynamicPanel, DragDropEffects.Move)
  34.         End If
  35.  
  36.     End Sub
  37.  
  38.     Private Sub DynamicPanel_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DynamicPanel.DragEnter
  39.  
  40.         e.Effect = DragDropEffects.Move
  41.     End Sub
  42.  
  43.     Private Sub DynamicPanel_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DynamicPanel.DragDrop
  44.  
  45.         Dim Pnl As Panel = CType(e.Data.GetData(GetType(Panel)), Panel) ' the result is nothing
  46.         e.Effect = e.AllowedEffect
  47.         Pnl.Location = New Point(e.X, e.Y) 'try change location here
  48.     End Sub
Jan 11 '08 #1
0 784

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by hemant_mishal | last post: by
reply views Thread by Lauren Quantrell | last post: by
2 posts views Thread by SamSpade | last post: by
3 posts views Thread by Ajay Krishnan Thampi | last post: by
6 posts views Thread by jojobar | last post: by
3 posts views Thread by VB Programmer | last post: by
reply views Thread by ViRi | last post: by
1 post views Thread by Darren | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.