I want to use the Infragistics tooltips, since they offer more appearance customisation than the standard System.Windows.Forms.ToolTip. However, I am experiencing difficulties getting them to display at all.
I have tried two methods. I’ll explain them below. This code is in my grid class, which extends UltraGrid.
1. Using UltraTooltipManager
private UltraToolTipInfo tooltip;
private UltraToolTipManager m_toolTipManager;
private void SetupToolTip()
{
m_toolTipManager = new UltraToolTipManager();
m_tooltip = new UltraToolTipInfo();
m_tooltip.Appearance.FontData.Name = "Verdana";
m_tooltip.ToolTipTitleAppearance.FontData.Name = "Verdana";
m_tooltip.Enabled = DefaultableBoolean.True;
}
...
public void ShowToolTip(string titleText_, string text_)
m_tooltip.ToolTipText = text_;
m_tooltip.ToolTipTitle = titleText_;
m_toolTipManager.SetUltraToolTip(this, m_tooltip);
Point loc = Cursor.Position;
loc.Offset(16, 16);
m_toolTipManager.ShowToolTip(this, loc);
2. Using Infragistics.Win.ToolTip
private Infragistics.Win.ToolTip m_tooltip;
m_tooltip = new Infragistics.Win.ToolTip(this);
m_tooltip.TitleFont = NinePointRegularVerdanaFont.GetFont();
m_tooltip.Font = NinePointBoldVerdanaFont.GetFont();
m_tooltip.TopMost = true;
m_tooltip.Show(loc);
In both of these implementations, whenever I call ShowTooltip the tooltip just doesn’t appear. Using System.Windows.Forms.ToolTip I simply call the Show method and it works fine.
I’m stuck as to why neither of the above methods work. Does anyone have any insights?
For your first approach, I don't think that you need to specifically call ShowToolTip if you've called SetUltraToolTip; however, given that it seems like you want precise control over showing the ToolTip, you can probably skip the SetUltraToolTip method yourself (as you likely don't need the manager since you're doing the work yourself).
As for your second approach, nothing seems wrong here. I tried this same approach using a derived .NET Button along with the Infragistics.Win.ToolTip object and the same code as you (except for the custom gets of the font) and they worked fine. I'm not sure how that method could screw this up either; have you tried this with "this.Font" just as a test? Are you sure that the cursor is on the screen? You could try "m_tooltip.Show(this.Parent.PointToScreen(this.Location));" just as a test for that aspect.
-Matt
Thanks for the responses.
govind999 - I neglected to explain the motivation for this. I have a number of columns which I need tooltips for - however the value I want to display in this tooltip isn't just the value in the cell. For example, I have cells containing images; the tooltip for these cells should contain explanatory text.
Matt - I've simplified my SetupToolTip() method just to try and get it working:
private void SetupToolTip(){ m_tooltip = new Infragistics.Win.ToolTip(this); // is "this" the right argument to use, given that "this" is my object extending UltraGrid?
m_tooltip.TopMost = true;}
My ShowToolTip() method is below:
public void ShowToolTip(string titleText_, string text_){ m_tooltip.ToolTipTitle = titleText_; m_tooltip.ToolTipText = text_; m_tooltip.Show(this.Parent.PointToScreen(this.Location));}
This still doesn't display my tooltip anywhere.
Are there any properties on the grid I need to set to stop it trying to display tooltips itself? (I know the grid has functionality to display tooltips if the contents of the cell don't fit in the visible width of the cell.)
Hi Davis,
hope my code helps you out if u wanna display tooltip for the grid cell or header ..
None of your suggestions worked I'm afraid.
Like I said, I think the Infragistics.Win.ToolTip may not work when used in a control which is hosted within a WindowsFormsHost.
That may be a possibility, I'm not sure how the WindowsFormsHost handles such things. You may want to submit an issue to developer support, but the WindowsFormsHost may prevent the showing of the tooltips without the ability to show a top-level window (just a guess).