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)

New Topic/Question
This topic is locked



MultiQuote







|