I’ve got a Picturebox, which the user can drag up or down. The PictureBox represents a note on a piano staff. When the note is moved up or down, the note’s position is to change relative to the staff lines. Hence, the positions can ONLY be moved to fixed positions (Y-values). Thus, when the user moves a note vertically, it is not supposed to be placed anywhere, but only in specified positions (dictated by the if statements).
The issue is that the user is able to move the PictureBox (music note) component down, but when the object is dragged up, nothing happens. The class inherits from PictureBox.
I would just like to emphasise that the PictureBox works when dragged downwards, but does not move when dragged upwards. The dragging is done in intervals, i.e. the PictureBox can only be placed in certain places (hence the need for specific co-ordinates).
Your code fails because the if statement when moving up includes the current position. E.g when this.Top is 138 and the mouse moved up you’ll hit this if statement:
else if (this.Top < 148 && this.Top >= 138)which will set the top to 138 which it already was. You should move the=sign to the other side like this:if (this.Top <= 148 && this.Top > 138).