CodePudding user response:
This is drag the location of the code, change the case up too much trouble, write their own right,Dim label As New label With {
. The Text=DateTime. Now. ToString (" HHmmssfff ")
}
AddHandler label. The MouseDown, Sub (ss, ee) label, Tag=ee. The Location
AddHandler label. MouseMove, Sub (ss, ee)
If ee. The Button=MouseButtons. Left Then label. The Location +=ee. The Location - CType (label Tag, Point)
End Sub
Controls. The Add (label)
MouseDown and MouseMove need to determine the current operation is a "drag" or "change" size, judgment method is: when the MouseDown coordinates, if the mouse coordinates, located within eight points, represents the change size, or drag
x between label. Location. X ~ label. The location.. X + 10 or label location. X + label. The width/2-5 ~ label. The location, x + label. The width/2 + 5 or label location. X + label. The width - 10 to label. The location, x + label. The width
And Y between the label. The location. ~ label. The Y location. Y + 10 or label. The location. The Y + label. The height/2-5 ~ label. The location, Y + label. The height/2 + 5 or label location. Y + label. The height - 10 ~ label. Location. Y + label. Height
MoseMove, I give out is dragging code above, if you want to adjust the size, the width and height and the difference in value (the current coordinates - original coordinates), and there is a need to pay attention to place, to the left or up, need to keep the bottom right hand corner is fixed, which is to change the label location in real time