Notifications
Clear all

[Closed] constraining label movement in dotnet forms

How do I constrain a label on a dot net form, so that the user can only move vertically, say?

5 Replies
 lo1

How is the user moving the label?

Just with a mouse. LB press and move…

 lo1

I mean – you are the one who coded the movement logic, aren’t you? so just make the x coordinate of the new point constant.

Thanks Io, but my problem is that , when I code somehing like this to have the label track with the mouse;


fn mouseMovelb sender arg= 
(
 if arg.button==arg.button.left do
 (
  sender.location=(sender.parent.PointToClient sender.MousePosition)
  lb0.location.y = sender.location.y
  lb0.location.x  =0
 
 )
 
)
 

which works, when the user releases the mouse, the label is constrained to the specified ordinate, but I get an ugly streak as the user drags the label around . I was looking for something cleaner…

 lo1

you are changing the location 3 times. Try this


fn mouseMovelb sender arg= 
(
 if arg.button==arg.button.left do
 (
  local pt1 = sender.parent.PointToClient sender.MousePosition
  lb0.location = dotnetObject "System.Drawing.Point" 0 pt1.y
 )
 
)