In Winform, The ListView mouse moves and the toolTip displays information, listviewtooltip

Source: Internet
Author: User

In Winform, The ListView mouse moves and the toolTip displays information, listviewtooltip

I used ListView when I was working on a hotel management system today. I suddenly thought about whether I could provide details about the specific room when I move my mouse over a certain item!

 

First, set the MouseMove event of Listview.

 

1. Get the current coordinate item

ListViewItem lvi = this. listView. GetItemAt (e. X, e. Y );

 

2. Determine whether a selected item exists. If yes, the corresponding information is displayed.

If (lvi! = Null)

{

ToolTip. show ("Test", listView, new Point (e. X, e. Y), 1000 );

ToolTip. Active = true;

}

: There is a problem. When you place the cursor over an item, the information is flashing constantly! The reason is that when the mouse does not move, it will also respond to the event, and all the problems will be solved by adding the following code.

 

First define a variable private Point pointView = new Point (0, 0); // location

Then, make judgments when displaying information.

If (pointView. X! = E. X | pointView. Y! = E. Y) // prevents flickering

{

ToolTip. show ("Test", listView, new Point (e. X, e. Y), 1000 );

PointView. X = e. X;

PointView. Y = e. Y;

ToolTip. Active = true;

} Else

{

ToolTip. Hide (listView );

PointView = new Point (e. X, e. Y );

}

 

Above, solve the problem!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.