Detect mouse leaving from a list view item

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mohit

    #1

    Detect mouse leaving from a list view item

    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!!
  • =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=

    #2
    RE: Detect mouse leaving from a list view item

    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_Mouse Move(object sender, MouseEventArgs e)
    {
    if (listView1.HitT est(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



    "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!!
    >

    Comment

    • Mohit

      #3
      Re: Detect mouse leaving from a list view item

      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??

      Comment

      Working...