C# MouseEventsArg e中可能缺少属性

C# MouseEventsArg e中可能缺少属性,c#,winforms,events,visual-studio-2013,mouse,C#,Winforms,Events,Visual Studio 2013,Mouse,因此,我正在尝试设置一个函数,允许我用鼠标在windows窗体上移动对象,而使用MouseEventsArg e似乎就是这样。我一直在尝试使用.button、.location、.X和.Y等属性,因为这是我在谷歌搜索问题时最常看到的弹出窗口。但我不断收到错误,告诉我这些属性没有定义。我去看Mouseeventsarge,我看到的是。按钮左、。按钮右、。按钮等等。是我遗漏了什么,还是我太愚蠢了 private void mouseLocation; private void button1

因此,我正在尝试设置一个函数,允许我用鼠标在windows窗体上移动对象,而使用MouseEventsArg e似乎就是这样。我一直在尝试使用.button、.location、.X和.Y等属性,因为这是我在谷歌搜索问题时最常看到的弹出窗口。但我不断收到错误,告诉我这些属性没有定义。我去看Mouseeventsarge,我看到的是。按钮左、。按钮右、。按钮等等。是我遗漏了什么,还是我太愚蠢了

 private void mouseLocation;

 private void  button1_mousedown (object sender,       MouseEventArgs e)
{
      if (e.Button == System.Windows.Forms.MouseButtons. Left)
   {
     Mouse Location = e.Location;
   }

private void button1_MouseMove  (object sender, MouseEventArgs e)
{
     if (e.button == System.Windows.Forms.MouseButtons.Left)
   {
       this.Left = e.X + this.Left - MouseLocation.X;
       this.Top = e.Y + this.Top - MouseLocation.Y;
    }
} 
(如果这看起来很糟糕,很抱歉,我是在手机上执行此操作的。)

您想使用NOT
MouseEventArg

MouseEventArgs类 为、和事件提供数据


你看的是正确的班级吗?否则,把你的密码寄出去。好的,我在电话里寄。我将在稍后发布代码。代码可以正常工作(忽略明显的打字错误)。您如何获得buttonLeft和buttonRight属性尚不清楚。是否可能重复?看起来很相似,既谈论控件,又移动控件。可能会也可能不会帮助提问者。这是一个老鼠夹。我很抱歉。现在我又在用手机做这件事了。我编辑it@Echo_ghost是否使用System.Windows.Forms命名空间?