I'm using MouseMove, MouseUp, MouseDown events to move a borderless form (as found here as an example).
It works great, but for a ListView, it only works if I click on an item (its text) in the list. It does not work if I click in the space of the ListView containing no items.
Is there a possible way to fix this?
private bool mouseDown;
private Point lastLocation;
private void ListView1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
lastLocation = e.Location;
}
private void ListView1_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);
this.Update();
}
}
private void ListView1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}