By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Detect mouse leaving from a list view item

P: n/a
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!!
Oct 8 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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!!
Oct 8 '08 #2

P: n/a
Hi,
Thanks Ciaran for your response.

Even after adding up cursor check it is still causing up to lots of
overhead and hanging up the application. CPU utilization clock is
showing up 100% usage when mouse is moved over the list view and
various items for a considerable amount of time.

Is there some other alternative exist??
Oct 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.