문제

I'm trying to make an application in C# and when i try relating a control to this.Top it keeps adding the distance between the Form and the Screen's edge. What should i do so I could use the top of the Form as Top?

Part of Code:

 if (Cursor.Position.Y > (this.ClientRectangle.Top + pCsuszka2.Height / 2) && Cursor.Position.Y < (this.Height -  pCsuszka2.Height / 2))
        {

            pCsuszka2.Top = Cursor.Position.Y - (pCsuszka2.Height / 2);

        }
도움이 되었습니까?

해결책

If you're in one of the mouse event handlers, you can use the MouseEventArgs parameter. It seems to give you relative position on the form.

   private void Form1_MouseUp(object sender, MouseEventArgs e)
    {
        this.Text = e.X.ToString() + ", " + e.Y.ToString();
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top