Вопрос

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