Newline in tooltip control

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Lembasts
Posts: 217
Joined: Thu Mar 15, 2012 9:47 am

Newline in tooltip control

Post by Lembasts » Tue May 28, 2019 5:49 pm

Hi,
According to: https://www.sapien.com/blog/2014/01/30/ ... p-control/
..all I need do for a new line in my tooltip is add a backtick n (`n).
I have done that on a tooltip and it does not generate a newline and simply display the text `n.
What am I missing please?
Thanks
David

jvierra
Posts: 13915
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Newline in tooltip control

Post by jvierra » Tue May 28, 2019 6:56 pm

The string must be in double quotes.

$tip = "this is one line `n and this is two lines"

User avatar
Lembasts
Posts: 217
Joined: Thu Mar 15, 2012 9:47 am

Re: Newline in tooltip control

Post by Lembasts » Tue May 28, 2019 7:31 pm

Thanks.
I also discovered that you cannot set that tootltip text directly in the controls properties.
You have to use the settooltip method.

jvierra
Posts: 13915
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Newline in tooltip control

Post by jvierra » Tue May 28, 2019 8:05 pm

That is correct. You cannot easily use the tooltip property on a control. It is just there to display a defult tip.

Attached is a demo of how to use a tooltip without any code.

Read the following very carefully to learn how ToolTips work.

https://www.sapien.com/blog/2014/01/30/ ... p-control/
Attachments
test-tootip.psf
(24.34 KiB) Downloaded 24 times

jvierra
Posts: 13915
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Newline in tooltip control

Post by jvierra » Tue May 28, 2019 8:15 pm

Lembasts wrote:
Tue May 28, 2019 7:31 pm
Thanks.
I also discovered that you cannot set that tootltip text directly in the controls properties.
You have to use the settooltip method.
My example shows how to use the tooltip set on the control.

Locked