tags:

views:

1486

answers:

3

I have a calendar control derived from DataGridView. A custom item hover event is already in place. When handling the event, I have the item that was hovered and the mouse location. What is the best method to show a pop-up window with detailed information about the item? Should I use a stripped down form (no titlebar,controlbox, etc) and simply close it on the MouseLeave? Is there a better way?

Thanks!

+2  A: 

Any type of Control, a Panel, a UserControl, etc. These will do as long as they doesn't have to pop outside the current form. If it needs to pop outside you might need to use a Form as you stated and removes it's border.

Pre create the Control or Form in the main form, then when the mouse hover the needed control, make the pop control visible, and when the mouse leaves, make it invisible.

Just watch out for the mouse events though, they could get caught by the newly poped control. This might require a little positioning gymnastic as you will have to offset the position so that the cursor never gets to hover the poped control.

Take example on Microsoft Windows tooltip.

Coincoin
Just so I understand it correctly...I'll add a panel to my form and hide it. When the hover occurs, I'll set the panel location, make it visible and set it on top of the Calendar control? I'm guessing I should use LostFocus to popdown the panel?
dotjoe
To remove the panel, just set Visible=false. But you just made me realise this wont pop outside the form. I'll update my answer.
Coincoin
A: 

I use thickbox (jQuery plugin) for popup windows like this. It allows you to use various methods to display data (ajax, iFrame), you can also setup callbacks from the popup in case you need to capture data. If you want to see how I've used it recently you can click on any of the demo links on this page:

http://www.prolifiq.net/Corporate/inaction.aspx

Ryan Eastabrook
A: 

Ended up using a stripped down form. To auto-close it, I start a timer on the load event and on each tick I check if the cursor position is still inside the form. Works pretty good.

dotjoe