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.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

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 1934 times
Howevew i would like to change default color of this as well :
02.JPG
02.JPG (36.88 KiB) Viewed 1934 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked