Hi All - At the moment, I am working with 22 table layout panels on my form. I am now trying to find a way (if there is one) to allow moving controls on my form with less code. I am using the below code for the panel to allow moving and then saving the new location. Is there a function for this to allow moving any of the panels and saving each one to my.settings without creating this much code for a single panel?
Code:Private allowTLPmove As Boolean = False Private newTLPpoint As New Point Private Sub TableLayoutPanel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel1.MouseDown allowTLPmove = True newTLPpoint = New Point(e.X, e.Y) Me.Cursor = Cursors.SizeAll End Sub Private Sub TableLayoutPanel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel1.MouseMove If allowTLPmove = True Then TableLayoutPanel1.Location = New Point(TableLayoutPanel1.Location.X + e.X - newTLPpoint.X, TableLayoutPanel1.Location.Y + e.Y - newTLPpoint.Y) End If End Sub Private Sub TableLayoutPanel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel1.MouseUp allowTLPmove = False Me.Cursor = Cursors.Default My.Settings.TblPanel1 = TableLayoutPanel1.Location My.Settings.Save() End Sub




Reply With Quote
