Font and Text Style

Developers can modify the appearance of the text within the control by toggling font styles and applying text transformations, ensuring that the control’s typography matches the app, etc.

Overview

The Font & Text Style Customization feature is managed through several public properties that control the font styling and text transformation behavior. This includes toggling bold, italic, underline, and strike-through styles, as well as specifying whether the text should appear in its normal form or be converted to uppercase or lowercase.

Property
Type
Default
Description

IsBold

bool

false

When set to true, renders the text in a bold font style.

IsItalic

bool

false

When enabled, displays the text in italic style.

IsUnderline

bool

false

When set to true, underlines the text.

IsStrikeThrough

bool

false

When enabled, draws a strike-through line over the text.

TextCaseMode

TextCase (enum)

Normal

Determines whether the text is displayed as typed (Normal), transformed to all uppercase (Upper), or to all lowercase (Lower).

The control applies these styles dynamically, updating the font via an internal helper (e.g., UpdateFont) whenever one of these properties changes. This ensures that any modifications to the font style or text case are immediately reflected in the rendered output.


Key Points

Aspect
Detail

Dynamic Font Styling

The IsBold, IsItalic, IsUnderline, and IsStrikeThrough properties allow for real-time toggling of font appearance.

Text Transformation

The TextCaseMode property ensures that text can be standardized (all uppercase or lowercase) to meet formatting requirements.

Immediate Feedback

Changes to any text styling property automatically trigger an update of the control’s font, ensuring the user sees changes instantly.


Best Practices

Practice
Explanation

Consistent Styling Across Controls

Use the same combination of font styles (bold, italic, underline, strike-through) across similar controls for a uniform user experience.

Use Text Transformation Judiciously

Apply TextCaseMode only where necessary to maintain the intended meaning and readability of the text.

Test Different Combinations

Verify that various combinations of IsBold, IsItalic, IsUnderline, and IsStrikeThrough do not conflict and are visually balanced.

Integrate with Overall UI Theme

Ensure that the chosen font styles and text transformation settings align with your application’s typography and overall theme.


Common Pitfalls

Pitfall
How to Avoid

Overuse of Multiple Font Styles

Applying too many styles simultaneously (e.g., bold, italic, underline, strike-through) may reduce readability; choose a clear visual hierarchy.

Ignoring TextCaseMode Effects

When converting text to upper or lower case, ensure that the underlying data is not adversely affected if case sensitivity is important.

Inconsistent Font Updates

Avoid manually setting the Font property outside of the provided styling properties; instead, rely on the control’s internal UpdateFont logic.


Usage Scenarios

Scenario
Example Use Case

Emphasizing Important Information

Use IsBold or IsUnderline to highlight critical parts of a phone number or accompanying instructional text.

Standardizing Input Data

Apply TextCaseMode to automatically convert user input to uppercase or lowercase, ensuring consistency for storage or display.

Creating Read-Only Displays with Distinct Style

Combine multiple font styling properties (e.g., italic with strike-through) to indicate that the displayed text is non-editable or marked as obsolete.


Code Examples

Example 1: Basic Font Style Customization This sample demonstrates how to enable bold and italic styling on the phone number text.

// Instantiate the control
SiticonePhoneNumberBox phoneNumberBox = new SiticonePhoneNumberBox();

// Enable bold and italic font styling
phoneNumberBox.IsBold = true;
phoneNumberBox.IsItalic = true;

// Set text alignment and case mode (optional)
phoneNumberBox.TextAlign = TextAlignment.Left;
phoneNumberBox.TextCaseMode = TextCase.Normal;

// Position and add to the form
phoneNumberBox.Location = new Point(20, 20);
phoneNumberBox.Size = new Size(250, 40);
this.Controls.Add(phoneNumberBox);

Example 2: Applying Underline and Strike-Through This example shows how to toggle underline and strike-through for a distinct visual effect.

SiticonePhoneNumberBox phoneNumberBox = new SiticonePhoneNumberBox();

// Enable underline and strike-through styling
phoneNumberBox.IsUnderline = true;
phoneNumberBox.IsStrikeThrough = true;

// Optional: Set text transformation to uppercase for standardization
phoneNumberBox.TextCaseMode = TextCase.Upper;

// Position the control
phoneNumberBox.Location = new Point(20, 80);
phoneNumberBox.Size = new Size(250, 40);
this.Controls.Add(phoneNumberBox);

Example 3: Enforcing Text Case Transformation This sample demonstrates how to convert all entered text to lowercase for consistency.

SiticonePhoneNumberBox phoneNumberBox = new SiticonePhoneNumberBox();

// Set text case mode to convert all text to lowercase
phoneNumberBox.TextCaseMode = TextCase.Lower;

// Position and configure the control
phoneNumberBox.Location = new Point(20, 140);
phoneNumberBox.Size = new Size(250, 40);
this.Controls.Add(phoneNumberBox);

Review

Aspect
Review Comment

Styling Flexibility

The feature provides comprehensive options to control font appearance, offering flexibility through multiple style toggles.

Immediate Visual Updates

The internal UpdateFont mechanism ensures that any change to the font styling properties is immediately rendered.

Text Transformation Consistency

The TextCaseMode property simplifies ensuring that input adheres to a desired format, which is especially useful for data consistency.


Summary

The Font & Text Style Customization feature of the SiticonePhoneNumberBox control empowers developers to tailor the visual presentation of text. By leveraging properties such as IsBold, IsItalic, IsUnderline, IsStrikeThrough, and TextCaseMode, you can ensure that the text displayed within the control matches your application’s design requirements and data formatting standards. This results in a more polished and consistent user interface.


Additional Notes

Note Type
Detail

Extensibility

The font styling properties can be modified at runtime, allowing dynamic adjustments based on user interactions or theme changes.

Integration Tips

Combine text style customization with other visual features (such as border and background settings) for a cohesive overall design.

Debugging

Monitor changes to the control’s font and verify that UpdateFont is invoked appropriately when any of the text styling properties are modified.

Last updated