.NET Control: Color and Font Properties

About this task

Many .NET control properties are unique to the selected control. However, in most cases colors/brush types and fonts that are included in the control can be changed in the Properties - Object dialog box>Control Properties.

  • .NET Control: Select colors and brush types.
  • .NET Control: Select fonts.

.NET Control: Select Colors and Brush Types

When using Component Hosting, the Windows Forms color (System.Drawing.Color) and WPF color (System.Windows.Media.Color) types are converted to the COM color type (OLE_COLOR) so the two .NET color types can be configured with the standard Windows palette.

  • Color: Color
  • Color: Brush types.

Color: Color

Procedure

  1. Right-click a .NET control>select Properties on the Popup menu.

    The Properties - Object dialog box opens.

  2. Select Control Properties.
  3. Click the Palette button to the right of the control color you want to change.

    \

    A standard Windows color palette opens.

  4. Select a color.

    Selection options include the following.

    A Palette tab Click a preconfigured color on any of the Palette tab color groups. Note: Use the Forward/Back scroll buttons to display available preconfigured color groups. Result: The preconfigured color is selected for the control.
    B Advanced palette Right-click a reserved color box on the Palette tab. Configure a custom color in the Advanced Color dialog box. Click Add Color. Result: The configured color is:
    • Added to the selected box on the Palette tab.
    • Selected for the control.

    Color: Brush Type

    Brush types are available for most WPF control parts that can be colored.

    Brush Type Options are as follows.

    • BrushType_Solid
    • BrushType_Linear
    • BrushType_Radial

    BrushType_Solid

    Select one color.

    Select BrushType_Solid for the selected color area, e.g. Background_Type.

    Result: The selected color area will display one solid color.

    BrushType_Linear

    A linear brush provides a "straight line" gradation in which one color gradually changes to another. You can select where in the gradation, each color will begin and end.

    Select BrushType_Linear in the ...Type field for the selected area.

    Required configuration entries include the following.

    Field Description
    A ...Color1/...Color2 Two colors are required for a Linear brush type.
    B ...Point1X/Point1Y X and Y coordinates of the gradient starting position
    C ...Point2X/Point2Y X and Y coordinates of the gradient ending position

    BrushType_Radial

    A radial brush provides a circular gradation in which one color starts at a center point and gradually changes to another. You can select where in the gradation, each color will begin and end.

    Select BrushType_Radial in the ...Type field for the selected area.

    Required configuration entries include the following.

    Fields Description
    A ...Color1/...Color2 Two colors are required for a Linear brush type.
    B ...Point1X/Point1Y Color1 color position. Coordinates of the gradient center.
    C ...Point2X/Point2Y Color2 color position X and Y radii of the gradient ending ellipse

    .NET Control: Select Fonts

    Font configuration options are based on the control type.

    • Fonts: Windows forms-based controls.
    • Fonts: .NET WPF controls

    Fonts: Windows Forms-based Controls

    Windows Forms-based controls use the standard Font dialog box to configure font.

  5. Open a Properties dialog box for a Windows Forms-based control.
  6. Select Control Properties.
  7. Click the Font button to the right of the field.

    A Font dialog box opens.

  8. Select the font properties: font, Font style, Size and Effects.

    Note: Script does not work for standard WinForm controls.

  9. Click OK.

    Result: The selected font displays in the Font field; the text in the control displays the new font selections.

    Note:
    • In most instances, you can change the font color in the FontColor field. Select a solid color the same way you select a color for any control feature that enables color selection.
    • A Windows Forms-based control plain text box does not word wrap. The text that goes beyond the width of the box will not display.

    Fonts: .NET WPF Controls

    .NET WPF control font configuration is primarily located in the Control Properties list rather than in a separate Font dialog box. However, the Font dialog box is still available in order to select a font. The new configuration enables you to apply more granulated configuration to the font, both in style and color.

  10. Open a Properties dialog box for a .NET WPF control.
  11. Select Control Properties.
  12. Click the Font button to the right a Font Family field.

    A Font dialog box opens.

  13. Select the font that should display.

    Note: Only Font is applied to the control; all other font related properties in the Font dialog box are not applied

  14. Click OK.

    The Font dialog box closes.

  15. Select values for other Font properties, including the following.
    Field Description
    A Font Size The text display size in the Rich text box. Note: The size entered in this Font Size field is the size that is used, not the size that appears to be selected in the Font dialog box.
    B FontStretch Expands or contracts the text width, based on the selection. Selections can include, but are not limited to: FontStretch_Condensed FontStretch_Expanded FontStretch_ExtraCondensed FontStretch_ExtraExpanded FontStretch_Medium FontStretch_Normal FontStretch_SemiCondensed FontStretch_SemiExpanded FontStretch_UltraCondensed FontStretch_UltraExpanded
    C FontStyle Common styles (if the selected font includes them). Selections can include: FontStyle_Italic FontStyle_Normal FontStyle_Oblique
    D FontWeight The weight applied to each character. Note: Results can also depend on the selected font configuration capabilities. Selections can include, but are not limited to: FontWeight_Black FontWeight_Bold FontWeight_DemiBold FontWeight_ExtraBlack FontWeight_ExtraBold FontWeight_ExtraLight FontWeight_Heavy FontWeight_Light FontWeight_Medium FontWeight_Normal FontWeight_Regular FontWeight_SemiBold FontWeight_Thin FontWeight_UltraBlack FontWeight_UltraBold FontWeight_UltraLight
    E Foreground Both color and brush types can be applied to .NET WPF control fonts.