1 Replies - 503 Views - Last Post: 19 January 2013 - 05:12 PM Rate Topic: -----

#1 JeyT  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 18-January 13

Advanced TableLayoutPanel Drag and Drop - updated

Posted 19 January 2013 - 05:08 PM

This is a continuation of post my post at :
http://www.dreaminco...0&#entry1786350

The following is the code that I included with the wrong format. Sorry about that.




Private Sub TableLayoutPanel2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel2.MouseDown
Me.TableLayoutPanel2.DoDragDrop(Me.TableLayoutPanel2, DragDropEffects.Copy)
End Sub


Private Sub TableLayoutPanel1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TableLayoutPanel1.DragDrop

"VB"
'Define Point
Dim loc As Point = Me.TableLayoutPanel1.PointToClient(New Point(e.X, e.Y))

'detemine the cell location
Dim ColumnIndex As Integer = -1
Dim RowIndex As Integer = -1
Dim x As Integer = 0
Dim y As Integer = 0

While (ColumnIndex <= Me.TableLayoutPanel1.ColumnCount)
If (loc.X < x) Then
Exit While
End If
ColumnIndex = (ColumnIndex + 1)
x = (x + Me.TableLayoutPanel1.GetColumnWidths(ColumnIndex))

End While

While (RowIndex <= Me.tlpCurrent.RowCount)
If (loc.Y < y) Then
Exit While
End If
RowIndex = (RowIndex + 1)
y = (y + Me.TableLayoutPanel1.GetRowHeights(RowIndex))

End While
Me.TableLayoutPanel1.Controls.Add(lb, ColumnIndex, RowIndex)
End Sub


Private Sub TableLayoutPanel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TableLayoutPanel1.DragEnter
e.Effect = DragDropEffects.Copy
End Sub

''''''''''''''''''''''''''''''''''''

Part of the problem is that the cells with text in the tablelayoutpanels, are created programmatically from a database, which is working fine, but I can't figure out how to copy the cells that are created:

''''''''''''''''''''''''''''''''''''''''

tablelayoutpanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize, 10.0))
Dim t As New RichTextBox
tablelayoutpanel1.Controls.Add(t, 0, r)
''''''''''''''''' 



Is This A Good Question/Topic? 0
  • +

Replies To: Advanced TableLayoutPanel Drag and Drop - updated

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10437
  • View blog
  • Posts: 38,651
  • Joined: 27-December 08

Re: Advanced TableLayoutPanel Drag and Drop - updated

Posted 19 January 2013 - 05:12 PM

Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1