Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1100
How do I get my tooltip to wrap long strings?
posted

I am building the data for a Gantt chart at runtime.

This includes retrieving a long description string that I am setting for the Label.

 

Short of writing my own "\r\n" inserter to manually break the long desrciption string up, what can I do?

I have not found any tooltip attributes to help me...

 

 

Parents
No Data
Reply
  • 26458
    Verified Answer
    Offline posted

    Unfortunately, there's no automatic wrapping for the tooltip. I recommend using a custom label renderer to insert line breaks. The code in ToString below will fire once for each of the data points tooltips. Whatever you return in that method will be displayed as the tooltip on the screen.

    protected void Page_Load(object sender, EventArgs e)
    {
       Hashtable labelHash = new Hashtable();
       labelHash.Add("CUSTOM", new LabelRenderer());
       chart.LabelHash = labelHash; 

       chart.Tooltips.FormatString = "<CUSTOM>";
    }

    public class LabelRenderer : IRenderLabel
    {
        public string ToString(Hashtable context)
        {
            string myLabel = GetMyLabel();
            return myLabel;
        }
    }

Children