【问题标题】:Moving or dragging a program by a toolbox item [duplicate]通过工具箱项移动或拖动程序[重复]
【发布时间】:2017-02-17 17:58:02
【问题描述】:

我正在处理一个 C# 项目,并且我已经删除了表单边框,因此用户无法拖动程序。我需要他们能够通过菜单条或其他工具箱项而不是表单边框进行拖动。

Here 是我项目的顶部:

【问题讨论】:

标签: c# drag noborder


【解决方案1】:

在表单内任意点击拖动...

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
        {
            Location = new Point(this.Left - (mousePoint.X - e.X), this.Top - (mousePoint.Y - e.Y));
        }
    }

    Point mousePoint = new Point(0, 0);

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        mousePoint = new Point(e.X, e.Y);
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    • 1970-01-01
    • 2015-09-06
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    相关资源
    最近更新 更多