Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 611

Handle MouseMove, MouseDown, MouseUp Events in a ListView to drag a borderless Form

$
0
0

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;}

Viewing all articles
Browse latest Browse all 611

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>