Custom Color for Tooltip on Menu Item

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.
Post Reply
User avatar
daniel kusnir
Posts: 40
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Thu May 25, 2017 8:22 am

Custom Color for Tooltip on Menu Item

Post by daniel kusnir »

Hello

is it possible to change coloring property for ToolStripMenuItem ? i see that they are using different class - tooltiptext which does not have coloring

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

Re: Custom Color for Tooltip on Menu Item

Post by jvierra »

It i snot possible to understand wat you are asking. Are you asking about a tooltip or a menuitem?
Here are all of the properties of a ToolStripMenuItem: https://docs.microsoft.com/en-us/dotnet ... etcore-3.1

You can only change the global color settings of a tooltip control. You can set "OwnerDraw True" and handle the graphical rendering of the tooltip.

You can change the color of a menu item on the "Paint" event for the item.

User avatar
daniel kusnir
Posts: 40
Joined: Thu May 25, 2017 8:22 am

Re: Custom Color for Tooltip on Menu Item

Post by daniel kusnir »

sorry i wasnt very specific. I would like to know if there is a way to change Colors of a tooltip for a toolstripmenuitem.

Those are however handled by custom class and for those owner draw does not apply. I can create custom colors for most except menu items :
01.JPG
01.JPG (40.38 KiB) Viewed 338 times
Howevew i would like to change default color of this as well :
02.JPG
02.JPG (36.88 KiB) Viewed 338 times

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

Re: Custom Color for Tooltip on Menu Item

Post by jvierra »

YOu can set OwnerDraw and use this to set the background:

Code: Select all

$tooltip1_Draw=[System.Windows.Forms.DrawToolTipEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.DrawToolTipEventArgs]
    $r = [System.Drawing.RectangleF]::new($_.ClipRectangle.Location.X,$_.ClipRectangle.Location.Y,400,400)
    $_.Graphics.FillRectangle([System.Drawing.Brushes]::Blue,$r)
}
This sets the color but you will need to add the text you want.

User avatar
daniel kusnir
Posts: 40
Joined: Thu May 25, 2017 8:22 am

Re: Custom Color for Tooltip on Menu Item

Post by daniel kusnir »

Thanks for the replay, however i think its a bit more complicated than that.

As you can see in the pictures, i wanted to change background of a tooltip for menu iteam, when you click Menu - > Item 2.

And unfortunatelly, this is controlled by ToolTipText property.

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

Re: Custom Color for Tooltip on Menu Item

Post by jvierra »

Yes. The drop down menu items for the toolstrip cannot be changed this way. Only the standard menu strip allows painting a background.

Post Reply