I have a VB.net windows form application that will be used for users(our inside people) to customize the locations of certain variable data fields for a particular customer's needs. Each product type has certain fields that are available to be used and all of the default information for them exists in tables.
When a certain product is selected I can make sample data appear as labels with a tooltip letting them know the name of the field. All of that works.
The issue I have is making the labels be movable after the defaults are loaded.
I have found examples of code to allow for labels made at development time to be moved, but nothing that allows for labels made on the fly to be movable.
The second part is to be able to retrieve the new X and y coordinates from a moved field so records can be made for that customer.
Here is the sub that creates the labels. It is called from inside a loop that iterates through the available field data. One note: the fields appear within a panel the background of which will be an image that will be used to know where data can be put.
Private Sub lblCreateLabel_Click(ByVal RecCount As Integer, ByVal FieldType As String, ByVal FieldName As String, ByVal FieldData As String, ByVal FieldWidth As Integer, ByVal FieldJustification As String, ByVal xpos As Integer, ByVal ypos As Integer, ByVal Color As String, ByVal Side As String, ByVal Font As String, ByVal FontSize As String, ByVal FontStyle As String, ByVal SetType As String)
Dim label1 As New Label
Dim intHorizontalAlignment As Integer = 0
Dim intFontStyle As FontStyle = Drawing.FontStyle.Regular
Select Case FieldJustification
Case "Center"
intHorizontalAlignment = 32
Case "Left"
intHorizontalAlignment = 16
Case "Right"
intHorizontalAlignment = 64
Case Else
intHorizontalAlignment = 16
End Select
Select Case FontStyle
Case "Reg"
intFontStyle = Drawing.FontStyle.Regular
Case "Bold"
intFontStyle = Drawing.FontStyle.Bold
Case "Italic"
intFontStyle = Drawing.FontStyle.Italic
Case Else
intFontStyle = Drawing.FontStyle.Regular
End Select
label1.Name = "txt" & RecCount
label1.Text = FieldData.Replace("&", "&&")
label1.Width = FieldWidth
label1.ForeColor = System.Drawing.Color.FromName(Color.Replace("Color[", "").Replace("]", ""))
label1.Location = New Point(xpos, ypos)
Dim tt As New ToolTip()
tt.SetToolTip(label1, FieldName)
If FieldType = "Address" Or FieldType = "Slug" Or FieldType = "ChurchName" Then
label1.AutoSize = True
Else
label1.AutoSize = False
End If
If FieldName.Contains("811PlaceStamp") Then
label1.AutoSize = True
End If
If FieldType = "Barcode" Then
label1.Height = 30
label1.BackColor = Drawing.Color.Transparent
Else
label1.BackColor = Drawing.Color.Transparent
End If
label1.TextAlign = intHorizontalAlignment
Try
label1.Font = New Font(Font, CInt(FontSize), intFontStyle)
Catch
End Try
If Side = "Face" Then
pnlEnvelopeFace.Controls.Add(label1)
label1.Refresh()
Else
pnlEnvelopeFlap.Controls.Add(label1)
label1.Refresh()
End If
End Sub```
Any guidance would be very much appreciated.