locked
Support for Tooltip max length? RRS feed

  • Question

  • Hello,

     

    The win32 native tooltip control supports a "max tip width" property (set via TTM_SETMAXTIPWIDTH), which causes long tooltips to wrap onto a new line to avoid excessively wide tooltips. I cannot find any such support in the builtin ToolTip control - does anyone know of an implementation that does support this? What would it take to get this added to the next framework release?

     

    Also, I already tried setting a narrower size in the Popup event, but that doesn't work properly because windows has already positioned the tooltip at an appropriate location for a very wide tooltip (in my case, the very left edge of the screen).

     

    Thanks,
    Charles Nevill

    Wednesday, August 8, 2007 10:01 PM

Answers

  • Hi Nevill,

     

    Have you set the ToolTip.OwnerDraw Property to true? I tried the following code, and it worked well on my machine.

    Code Snippet

    namespace ToolTipP

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

            }

     

            private void Form1_Load(object sender, EventArgs e)

            {

                this.toolTip1.SetToolTip(this.button1, "With the ToolTip class, you can provide hints to a user when the user places the pointer on a control. The ToolTip class is typically used to alert users to the intended use of a control. For example, you can specify ToolTip text for a TextBox control that accepts a name, specifying the format of the name to be typed into the control. In addition to providing hints, you can also use the ToolTip class to provide run time status information. For example, you can use the ToolTip ");

                this.toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);

            }

     

            private void toolTip1_Popup(object sender, PopupEventArgs e)

            {

                e.ToolTipSize. = new Size(400, 100);

            }

        }

    }

     

    Hope this helps.

    Regards

    Monday, August 13, 2007 8:47 AM