We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hover

I implemented the code in your FAQ to do hover from the MouseMove event (this seems wrong to me, seems like it should be MouseHover). By putting Debug.WriteLines in my handler I can see that I am activating the ToolTip control, but it never shows up. Any idea why? I pasted my MouseMove and FormLoad handlers below. Tx, curt private void gridDataBoundGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { int row, col; this.gridDataBoundGrid1.PointToRowCol( new Point( e.X, e.Y), out row, out col); if ( col >= 0 && row >= 0) { int x = 14; } if ( col >= myBeginSecuritesCol && row <= 2) { if ( myToolTip.Active == true) { Debug.WriteLine( "De-activating hover"); myToolTip.Active = false; } else { Debug.WriteLine( "Activating hover"); myToolTip.SetToolTip( this.gridDataBoundGrid1, "hello from tooltip"); myToolTip.Active = true; } } } private void GreenBoxCtl_Load(object sender, System.EventArgs e) { myToolTip = new System.Windows.Forms.ToolTip(); myToolTip.InitialDelay = 500; myToolTip.ReshowDelay = 0; }

5 Replies

CK Curtis Koppang February 24, 2003 07:44 PM UTC

I think this has something to do with the fact the the cells I want to display the tool tip on are header cells. Because if I change the target column range it does seem to work. Why would this work differently? BTW, the code you have on the FAQ has a bug. When you check if the mouse pos is in the range you are trapping, you toggle the tool tip active flag. Since it is possible to miss a mouse move (when moving very quickly) you need to also set the active flag to false when the cursor is outside the target range. I copied the corrected code below. later, curt private void gridControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { int row, col; if(this.gridControl1.PointToRowCol(new Point(e.X, e.Y), out row, out col) && (col != hooverCol || row != hooverRow)) { hooverCol = col; hooverRow = row; if(this.toolTip1 != null && this.toolTip1.Active) this.toolTip1.Active = false; //turn it off this.toolTip1.SetToolTip(this.gridControl1, string.Format("tooltip: row {0}, column {1}", hooverRow, hooverCol)); this.toolTip1.Active = true; //make it active so it can show } else { this.toolTip1.Active = false; } }


AD Administrator Syncfusion Team February 25, 2003 08:57 AM UTC

I dropped a GridDataBoundGrid into the sample from the KB. Attached is what I got. With this code, there does not seem to be a problem with getting the tooltip over headers. I might be missing something here, but I am not sure you want to add the else clause to turn off the tooltip if you are not over a different cell. The MouseMove will continue to be hit as you move the mouse over the same cell. If you turn it off on the second hit of MouseMove over the same cell, the tip cannot be displayed. The reason the MouseMove is used instead of MouseHover is that these are Control inherited events. Thus MouseHover is only fired once for teh entire grid. It is not continuously fired as you move the mouse from cell to cell. Actually, in an upcoming release, we will fire cell versions of these mouse events.


CK Curtis Koppang February 25, 2003 11:55 AM UTC

In this sample I trap for the hover over the header cell which has the word Turbo in it. Yet the tool tip is never visible. Tx, curt


AD Administrator Syncfusion Team February 25, 2003 12:56 PM UTC

Your zip did not appear to include TestData.xml. Could you attach it? Thanks.


AD Administrator Syncfusion Team February 25, 2003 01:02 PM UTC

Now I could not try this becuase of the missing data, but I would suggest you try this code.
private bool over55 = false;
private void gridDataBoundGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
	int row, col;

	this.gridDataBoundGrid1.PointToRowCol( new Point( e.X, e.Y), out row, out col);

	if ( col == 5 && row == 5 && !over55) 
	{
		if ( myToolTip.Active == true)
		{
			Debug.WriteLine( "De-activating hover");
			myToolTip.Active = false;
		}
		else
		{
			Debug.WriteLine( "Activating hover");
			myToolTip.SetToolTip( this.gridDataBoundGrid1, "hello from tooltip");
			myToolTip.Active = true;
		}
		over55 = true;
	}

	if ( col != 5 || row != 5)
		over55 = false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon