Search code examples
c#infragistics

Is there any way to display a less than sign < in a popup using Infragistics UltraToolTipManager / UltraToolTipInfo?


I have been struggling with this for a couple of days now.

I can't find a way to display a < symbol or > symbol in a popup using Infragistics UltraToolTipManager and UltraToolTipinfo without it breaking the ability to display formatted text such as bold. So if I include a < symbol the other HTML tags in the popup are not rendered because the HTML is broken due to an extra < symbol.

I have tried using HTML entities but that has made no difference.

Thanks for reading, here is my code:

    private void button3_MouseHover(object sender, EventArgs e)
    {
        UltraToolTipInfo info = new UltraToolTipInfo();
        info.ToolTipTextStyle = ToolTipTextStyle.Formatted;

        String tooltipText = "x < y <br/><br/> <span style=\"font-weight:bold;\">This is bold.</span> And this is not bold.";

        tooltipText = tooltipText.Replace("<", "&lt;");
        tooltipText = tooltipText.Replace(">", "&gt;");

        info.ToolTipTextFormatted = tooltipText;

        ultraToolTipManager1.SetUltraToolTip((Control)sender, info);
    }

Solution

  • You need to replace only those instances of < and > that you want displayed literally, not every instance:

     String tooltipText = "x &lt; y <br/><br/> <span style=\"font-weight:bold;\">This is bold.</span> And this is not bold.";