Page 1 of 1

Custom Color for Tooltip on Menu Item

Posted: Fri May 15, 2020 12:22 am
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

Re: Custom Color for Tooltip on Menu Item

Posted: Fri May 15, 2020 12:40 am
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.

Re: Custom Color for Tooltip on Menu Item

Posted: Fri May 15, 2020 2:07 am
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 343 times
Howevew i would like to change default color of this as well :
02.JPG
02.JPG (36.88 KiB) Viewed 343 times

Re: Custom Color for Tooltip on Menu Item

Posted: Sat May 16, 2020 11:26 am
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.

Re: Custom Color for Tooltip on Menu Item

Posted: Thu May 21, 2020 2:03 am
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.

Re: Custom Color for Tooltip on Menu Item

Posted: Thu May 21, 2020 3:53 am
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.