'c# tooltip backcolor and forecolor are not changing with using method or other ways
I want to use tooltips in my windows forms application. So i created a simple method like this:
public void MyTooltips(Control c, string m, bool b)
{
ToolTip t = new ToolTip();
t.IsBalloon = b;
t.SetToolTip(c, m);
t.BackColor = Color.Crimson;
t.ForeColor = Color.White;
}
And i am using it like this: MyTooltips(combobox1, "If anything, select zero.", true);
In the usage, tooltip back and fore colors are not changing. Tooltips shown as Windows 7 default tooltip back and fore colors. How can i do this?
Kind regards.
Solution 1:[1]
From the relevant MSDN article for the BackColor property:
Unless the ToolTip is owner-drawn, this property is ignored.
If you want to customise the colour of the ToolTip, you will have to set OwnerDraw to true and paint the control yourself (using the Draw event).
Solution 2:[2]
The MSDN help is not 100% accurate: BackColor does work if you don't enable visual styles: comment out the call to Application.EnableVisualStyles() in your Main(). But purists would probably advise that you shouldn't do that .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bradley Smith |
| Solution 2 |
