初めてこれを使うのですが、どうぞお手柔らかにお願いします。
プログラム初心者、約3週間です。
private void Button1_MouseDown(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { //位置を記憶する mousePoint = new Point(e.X, e.Y); } } private void Button1_MouseMove(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { this.Left += e.X - mousePoint.X; this.Top += e.Y - mousePoint.Y; //または、つぎのようにする //this.Location = new Point( // this.Location.X + e.X - mousePoint.X, // this.Location.Y + e.Y - mousePoint.Y); }
ヴィジュアルスタジオでボタンを作り、デバッグ開始、デバッグ中にボタンをフォーム上で移動できる様にしたいのですが、上のコードを打ち込んだのですが、ボタン単体ではなくフォーム全体が一緒に動いてしまいます。
どうしたらいいのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/05 01:27