One pretty old principle in user interface design is to be consistent with your color schemes. The term that was most frequently used is trichromacy, or three colors. The basic idea is stick to three primary colors for the features of your GUIs. However, color in small doses—icons, tool tips, graphics, text highlighting, errors—can be useful in signifying important information or drawing attention to something unusual. And, of course, there are some instances where you may want to deviate from basic color schemes.
To aid in helping you provide a consistent appearance the DevExpress WinForms controls use the DevExpress.LookAndFeel namespace and the concept of Style and Skin information for WinForms. This applies to the SuperToolTips too. If you don’t know a SuperToolTip behaves like a ToolTip, but permits you to define Title, Content, and Footer and associate graphics with each region. This results in a much richer tool tip experience for the end user—see Figure 1, from the DevExpress help documentation ms-help://MS.VSCC.v90/MS.VSIPCC.v90/DevExpress.NETv9.3/DevExpress.XtraUtils/clsDevExpressUtilsSuperToolTiptopic.htm.
Figure 1: A SuperToolTip from the DevExpress VS help documentation.
The challenge is that if you elect to deviate from the LookAndFeel applied, for instance you want to change the BackColor of a single component to draw special attention to it, then you need to know that the Appearance.BackColor and Appearance.BackColor2 properties are ignored if a LookAndFeel.Style is being applied. Listing 1 shows you how to programmatically define a SuperToolTip and to get the Appearance.BackColor property to be applied. If you set Appearance.BackColor2 to Color.Empty then you get a solid color for the BackColor; if you provide an actual color for Appearance.BackColor2 then the second color acts as the end color for a gradiently-shaded background color.
Listing 1: Create a SuperToolTip on the fly and override the LookAndFeel, enabling the BackColor property to be rendered.
SuperToolTip tooltip = new SuperToolTip();
// Create a tooltip item that represents a header.
ToolTipTitleItem titleItem1 = new ToolTipTitleItem();
titleItem1.Text = "Dynamic ToolTip";
ToolTipItem item1 = new ToolTipItem();
item1.Text = "This is the LabelControl Tip";
// Add the tooltip items to the SuperTooltip.
tooltip.Items.Add(titleItem1);
tooltip.Items.Add(item1);
tooltip.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
tooltip.Appearance.Options.UseBackColor = true;
tooltip.Appearance.BackColor = Color.Green;
//sTooltip1.Appearance.BackColor2 = Color.Empty;
tooltip.Appearance.BackColor2 = Color.White;
labelControl1.SuperTip = tooltip;
The code creates a new SuperToolTip object and defines the title item. Next, a ToolTipItem is created and the title and item are added to the SuperToolTip.Items collection. Starting with the line tooltip.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat the application of the default style is overridden. Picking the Flat style along with Options.UseBackColor = true, and providing background color values the background color settings will come through. Finally the SuperToolTip object is assigned to whatever control—the SuperTip property—should have this particular tip associated with it.
If you want to uniformly change the LookAndFeel information then place a line of code similar to this one in the Form’s constructor for VB.NET or the Program.cs’s Main function in C#. Remember to add the semi-colon for the C# version.
DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Money Twins"
This blog was posted in response to a question posted in our forums on 12/21 by Jassim Rahma--http://community.devexpress.com/forums/p/84237/288967.aspx#288967—and builds on our extensive help documentation, in this instance Visual Studio help document http://www.devexpress.com/Help/?document=XtraUtils/clsDevExpressUtilsSuperToolTiptopic.htm&levelup=true.
Happy Holidays!