This seems to work fine for me. Never locks up. I dont know if you had an
issue with constantly setting the cursor. Thats why i check it before setting
it:
private void listView1_MouseMove(object sender, MouseEventArgs e)
{
if (listView1.HitTest(e.X, e.Y).Item == null && (this.Cursor !=
Cursors.Default))
{
this.Cursor = Cursors.Default;
}
else if (this.Cursor == Cursors.Default)
{
this.Cursor = Cursors.Hand;
}
}
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Mohit" wrote:
> Hi all,
> I am working on a windows application with a list view on a form.
> Now I wanted to show hand cursor when mouse is over list view item and
> default(arrow) cursor at other places.
>
> List view's ItemMouseHover event can tell me that mouse is on the
> item and here I can change my cursor to hand. But I have no clue to
> change it back to default cursor when mouse is moved out of the list
> view item.
>
> How can I detect that mouse is moved away/out of the list view
> item??
>
> I have also tried to use HitTest method of the list view in the
> MouseMove event but it is causing lots of overhead and sometimes hangs
> the application. So I am not using this option.
> Can someone give me an idea how to achieve it.
>
> Thanks!!
>