Anyone,
I'm trying to add a tooltip to my ultragrid when the user hovers over a cell. My first step was to just get the tooltip to display when the user was over a cell and then I was going to check for a specific cell in the next step. I can't get the following code to work to display the cell. I have the ultraToolTipManager on the form.
My code is below. Thanks, Kris
{
// Get the cell location.
// Get a refernce to the cell.
// Make sure the mouse is over a cell.
new Infragistics.Win.UltraWinToolTip.UltraToolTipInfo("Click Button", ToolTipImage.Info, "Delete Record", DefaultableBoolean.True);
// Display the tooltip.
ultraToolTipManager.SetUltraToolTip(igrdAgentPool, tipInfo);
ultraToolTipManager.ShowToolTip(igrdAgentPool);
}
else
ultraToolTipManager.HideToolTip();
Hi Mike,
Mike Saltzman"] Have you considering just using the ToolTipText property on the cell? The InitializeRow event would be an excellent place to set this property.
Have you considering just using the ToolTipText property on the cell? The InitializeRow event would be an excellent place to set this property.
I did not realize that was an option. Are you saying I could do something like this:
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { for (int cellCounter = 0; cellCounter < e.Row.Cells.Count-1; cellCounter++) { e.Row.Cells[cellCounter].ToolTipText = e.Row.Cells[cellCounter].Value.ToString(); } }
And does that mean that I would be able to be assigning a different value to a tool tip specific to each cell at the time of row initialization? I need to pull the value for each cell from the database and have not gotten to that part of it yet...I was thinking this would be the easy part and I'd get it out of the way first. I was intending to take that additional value and add it to the tool tip on hover over a cell based on a cell key value both display values share. If I could do it at row initialization instead of at hover time that would be great.
How then do I get the tool tip to show up on hover over a cell?
Thanks,
Allen
Hi Allen,
Using MouseMove as below seems to work except that I seem to have a tool tip show up about 100 times per second; not sure why that is but it would be nice to have one tool tip on hover until I move to another cell.
private void ultraGrid1_MouseMove(object sender, MouseEventArgs e) { Infragistics.Win.UIElement myUIElement = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); try { Infragistics.Win.UltraWinGrid.UltraGridCell myCell = (UltraGridCell)myUIElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridCell)); if (myCell != null)//&&(!toolTip1.Active) ) { if (myCell.Column.Index > 1) { Random RandomNumber = new Random(); int iRandom = RandomNumber.Next(); toolTip1.Show("changing number for tooltip randomly to " + iRandom.ToString(), ultraGrid1); toolTip1.Active = true; } else { toolTip1.Active = false;//toolTip1.Hide(ultraGrid1); //MessageBox.Show("in ultraGrid1_MouseMove and hiding tooltip in else - column index < 2"); } } else { toolTip1.Active = false;//toolTip1.Hide(ultraGrid1); //MessageBox.Show("in ultraGrid1_MouseMove and hiding tooltip in else - not cell element?"); } } catch { } }
Don't know whether it is best to create a new post or to pose my questions in a post that I think is pertinent...
I'm trying to display a tooltip on hover over a cell. I need to know what cell it is because I need to display one value in the cell and an alternate value (particular to that cell) in a tool tip over the cell when the user hovers the mouse pointer over any cell.
I tried using if (e.Element is Infragistics.Win.UltraWinGrid.CellUIElement) from above but my element is not a CellUIElement on hover over a cell. I get RowUIElement followed by RowCellAreaUIElement and some others before it settles down but not CellUIElement. Why is that? Can I somehow use RowCellAreaUIElement to indicate I'm in a cell and can I also determine which cell from it?
I've tried approaching like this...
Infragistics.Win.UIElement myUIElement = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(new Point(e..X, e.Y));
...but it seems I don't have any coordinates in the MouseEnterElement event...I get the following error for both X and Y:
'Infragistics.Win.UIElementEventArgs' does not contain a definition for 'X' and no extension method 'X' accepting a first argument of type 'Infragistics.Win.UIElementEventArgs' could be found (are you missing a using directive or an assembly reference?)
Am I missing an assembly reference? I've got:
using Infragistics.Win;using Infragistics.Win.UltraWinGrid;
How to determine on hover a) that I'm in a cell and b) what cell I'm in.
Thanks.
Mike,
Thanks. The GetContext was what I was missing. I did find a lot of examples in the KB that is where I got the code I was using. Here is the code that I am using now.
Thanks a lot Kris.
// Get a refernce to the column.
// Show the tooltip only when it is over the "Delete" column.
new Infragistics.Win.UltraWinToolTip.UltraToolTipInfo("Click button to delete record.", ToolTipImage.Info, "Delete Record", DefaultableBoolean.True);
// Set the tooltip and it will be displayed automatically based on the tooltip manager settings.
//ultraToolTipManager.ShowToolTip(igrdAgentPool);