473,413 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Positioning a Form on DataGridView_MouseMoue()

I am creating a fixed size, windows form to be used as a tooltip, because I needs to control 'Opacity', that a regular tooltip does not allow. The issue I am having is that the form does correctly appear near my mouse pointer when hovering over the grid, but occasionally I see it flash very briefly outside the grid client area. It mostly happens when I first start the hover action. The flash is the result of the form momentarily appearing in the top left corner of the monitor outside of my client area. Any thoughts on why the form briefly appears outisde of the client area?
Expand|Select|Wrap|Line Numbers
  1. private void BidGrid_MouseMove(object sender, MouseEventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 // Hover code
  6.     if (EnableTooltips)                
  7.                     ShowHoverForm(BidGrid, new Point(e.X, e.Y), BidRowDictionary, true);
  8.  
  9.                             }
  10.             catch (Exception ex)
  11.             {
  12.                 MessageBox.Show("Exception BidGrid_MouseMove :" + ex.Message);
  13.             }
  14.         }
  15.  
  16.  
  17.  
  18. private void ShowHoverForm(BufferedDataGridView grid, Point mouseCoordinates, Dictionary<string, Lev2Order> dictionary, bool isBid)
  19. {
  20.         DataGridView.HitTestInfo hit = grid.HitTest(mouseCoordinates.X, mouseCoordinates.Y);
  21.  
  22.     if (hit.RowIndex != -1)
  23.     {
  24.  
  25.     if(hoverForm == null)
  26.        hoverForm = new HoverForm();
  27.  
  28.  
  29.     if(isBid)
  30.         hoverForm.Location = PointToScreen(new Point(mouseCoordinates.X + 10, mouseCoordinates.Y + 40));
  31.     else
  32.         hoverForm.Location = PointToScreen(new Point(AskGrid.Left + mouseCoordinates.X + 10, mouseCoordinates.Y + 40));
  33.  
  34.     hoverForm.ForeColor = gridLayout.HoverTooltipColor.TextColour;
  35.     hoverForm.BackColor = gridLayout.HoverTooltipColor.BackGroundColour;
  36.  
  37.     hoverForm.Opacity = Convert.ToDouble(gridLayout.HoverOpacity/100);
  38.  
  39.     //Confirm the new location is within the lev2 bounds
  40.      Rectangle rect = new Rectangle(this.PointToScreen(new Point(0, 0)), this.Size);
  41.  
  42.     if (rect.Contains(hoverForm.Location.X, hoverForm.Location.Y))
  43.      {
  44.         Trace.WriteLine("Hover location within lev2 bounds");
  45.         hoverForm.Show();
  46.      }
  47.      else
  48.         Trace.WriteLine("Hover location OUTSIDE lev2 bounds");                            
  49.     }
  50.     else
  51.     {
  52.         if(hoverForm != null)
  53.         {
  54.             hoverForm.Close();
  55.             hoverForm = null;
  56.         }
  57.     }
  58. }
  59.  
Aug 10 '10 #1
1 1455
It's fixed, turned out to be a Form property Form.StartPosition, had to be set to manual.
Aug 10 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Tom Szabo | last post by:
Hi, Just wondering if there are any disadvantage in absolute positioning controls on a page? In example instead of putting the text fields into a table to align properly, one would absolute...
4
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
7
by: Griff Miller | last post by:
Please see http://home.houston.rr.com/gmiller15/css/vertprob.html . In mozilla 1.6/1.7 it looks the way I want it, with a thin separation between the two boxes. In IE6, the two boxes touch, which...
2
by: hzgt9b | last post by:
Using Visual studio 2003 and VB.NET, I want to programatically position a control (windows media player) on my form. For example, I want to position the control in 1 of 9 locations: topLeft,...
5
by: Joe Bonavita | last post by:
My Web forms display differently on different machine with the same resolution. The pages are designed to fit in 800*600 res but on some machines with 800*600 the form appears too big. Are there...
1
by: Colin McGuire | last post by:
Thanks everyone for help in my previous post. Using the "Point.op_Addition" from the previous post I have to now focus on the real problem. I need to manually position a new form so that its...
6
by: | last post by:
I just installed VS 2005. Was working with 2003 and .Net 1.1. Trying to get the feel for a master page and I'm having some issues. I'm looking for a pretty basic setup. Standard header with an...
1
by: Hamed | last post by:
Hello I have a question about CHILD forms in an MDI form. How can I have a neat positioning of child windows in an MDI form? When I open a new child window in my MDI form it is opened in a...
1
by: Rich | last post by:
Hello, Is there a form property that can be set for positioning a form with respect to the parent? I could have sworn I saw such a property like Center window, or Parent something... But I...
1
by: OHM | last post by:
I havent done much with 2005 since 2003 Beta release, but Im not getting back into it and I have a question on the Subject Matter. If I change my positioning to absolute in the Positioning...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.