Boa tarde, amigos!
Estou realizando um código, e preciso manipular um evento para que meu form e meus componentes possam ser arrastados com a propriedade BorderStyleNone ativada. Até aí OK, porém gostaria de saber se teria como realizar um evento para vários componentes de
uma vez só??
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace teste
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
bool mouseDown;
Point lastLocation;
private void Login_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
lastLocation = e.Location;
}
private void Login_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
this.Location = new Point(
(this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);
}
}
private void Login_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
private void Panel1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
lastLocation = e.Location;
}
private void Panel1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
this.Location = new Point(
(this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);
}
}
private void Panel1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
lastLocation = e.Location;
}
private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
this.Location = new Point(
(this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);
}
}
private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
}
}
como mostra o código acima, tenho q ficar realizando o mesmo evento para vários componentes toda vez, teria como eu realizar uma vez só para todos ???