---
description: >-
  This feature customizes the look and feel of the form’s title bar, including
  its background, text, icon, and interactive behavior.
---

# Title Bar Customization

## Overview

This section covers the properties and behaviors that control the title bar's appearance and functionality. It includes settings for background color, text color, icon display, font styling, padding, and interactive behaviors such as double-click for maximize/restore.

***

### Key Points

| Aspect                    | Details                                                                                  | Default Value                 | Example Value                             |
| ------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------- | ----------------------------------------- |
| TitleBarBackColor         | Sets the background color of the title bar.                                              | WhiteSmoke (or theme default) | Color.DodgerBlue                          |
| TitleBarForeColor         | Sets the text color used for the form title on the title bar.                            | Black (or theme default)      | Color.White                               |
| FormTitle                 | Defines the text displayed on the title bar.                                             | "Form Title" (sample default) | "My Custom Application"                   |
| FormTitleFont             | Specifies the font used for the title text.                                              | Segoe UI, 9f, Bold            | new Font("Segoe UI", 11f, FontStyle.Bold) |
| TitleLeftPadding          | Sets the left padding (in pixels) before the title text starts.                          | 10                            | 15                                        |
| Icon                      | The icon displayed on the title bar and in the taskbar.                                  | (Depends on assignment)       | new Icon("appIcon.ico")                   |
| IconSize                  | Controls the displayed size of the title bar icon.                                       | 21                            | 24                                        |
| EnableTitleBarDoubleClick | When enabled, double-clicking the title bar toggles between maximized and normal states. | false                         | true                                      |

***

### Best Practices

| Recommendation                           | Explanation                                                                                                 | Example in Code                                                          |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Use clear, contrasting colors            | Ensure that the TitleBarBackColor and TitleBarForeColor offer sufficient contrast for readability.          | `TitleBarBackColor = Color.DodgerBlue; TitleBarForeColor = Color.White;` |
| Choose an appropriate font               | Select a FormTitleFont that aligns with your application’s branding and is legible at various sizes.        | `FormTitleFont = new Font("Segoe UI", 11f, FontStyle.Bold);`             |
| Adjust TitleLeftPadding for balance      | Modify TitleLeftPadding to ensure the icon (if present) and text are well spaced and centered.              | `TitleLeftPadding = 15;`                                                 |
| Enable double-click behavior judiciously | Use EnableTitleBarDoubleClick when it enhances user experience without conflicting with other interactions. | `EnableTitleBarDoubleClick = true;`                                      |

***

### Common Pitfalls

| Issue                           | Cause                                                                                   | Prevention/Remedy                                                      |
| ------------------------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| Title text hard to read         | Poor contrast between the title bar background and the text color.                      | Choose contrasting colors (e.g., dark background with light text).     |
| Icon appearing distorted        | IconSize is set too small or too large relative to the title bar height.                | Adjust IconSize and ensure the icon scales proportionally.             |
| Inconsistent title bar behavior | Changing the properties after the form is shown may not immediately update the display. | Set title bar properties during initialization or force an Invalidate. |

***

### Usage Scenarios

| Scenario                   | How It Works                                                                                              | Sample Code                                                                                                                                                                                                                                                                                                                                                           |
| -------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Custom branded application | The title bar is styled to reflect the company’s colors and fonts, displaying the logo and title clearly. | `csharp\nvar myForm = new SiticoneForm {\n FormTitle = "My Custom Application",\n TitleBarBackColor = Color.DodgerBlue,\n TitleBarForeColor = Color.White,\n FormTitleFont = new Font("Segoe UI", 11f, FontStyle.Bold),\n TitleLeftPadding = 15,\n Icon = new Icon("appIcon.ico"),\n IconSize = 24,\n EnableTitleBarDoubleClick = true\n};\nApplication.Run(myForm);` |
| Minimalist UI design       | The title bar is configured with subtle colors and minimal padding to create a sleek, modern look.        | `csharp\nvar myForm = new SiticoneForm {\n FormTitle = "Minimal App",\n TitleBarBackColor = Color.LightGray,\n TitleBarForeColor = Color.Black,\n TitleLeftPadding = 10\n};\nApplication.Run(myForm);`                                                                                                                                                                |

***

### Real Life Usage Scenarios

| Scenario                                      | Explanation                                                                                     | How to Implement                                                                                                  |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| Enterprise Application with Branding          | An enterprise-level application may require a title bar that reinforces corporate identity.     | Set TitleBarBackColor, TitleBarForeColor, FormTitleFont, and Icon properties to match the company’s style.        |
| Consumer-Facing Application with Intuitive UX | For better user experience, enabling double-click to maximize/restore enhances usability.       | Enable EnableTitleBarDoubleClick and adjust TitleLeftPadding and IconSize to ensure proper alignment and spacing. |
| Multi-monitor Desktop Applications            | Ensuring the title bar appears consistent across different DPI settings and screen resolutions. | Use IconSize scaling based on DPI (as shown in the code) and set consistent font sizes and padding values.        |

***

### Troubleshooting Tips

| Problem                                       | Potential Cause                                                                                    | Suggested Fix                                                                                                  |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Title text not updating after property change | Properties might be set after the form has already rendered.                                       | Update properties during initialization or call Invalidate() on the title bar control.                         |
| Icon not displaying correctly                 | The provided icon file may be incompatible or not scaled properly.                                 | Verify the icon file format and adjust IconSize; use high-quality icons if possible.                           |
| Double-click not toggling window state        | The EnableTitleBarDoubleClick property may be set to false or overridden by custom event handling. | Ensure EnableTitleBarDoubleClick is set to true and check if any event handler is preventing default behavior. |

***

### Review

<table><thead><tr><th width="242">Aspect</th><th>Notes</th></tr></thead><tbody><tr><td>Customization Flexibility</td><td>The title bar properties allow detailed customization of colors, fonts, icon, and interactive behavior.</td></tr><tr><td>User Experience</td><td>Enhancing readability and visual consistency improves the overall user experience.</td></tr><tr><td>Integration Complexity</td><td>Setting the title bar customization properties is straightforward and integrates seamlessly with the form.</td></tr></tbody></table>

***

### Summary

<table><thead><tr><th width="251">Summary Point</th><th>Description</th></tr></thead><tbody><tr><td>Visual Customization</td><td>Developers can precisely control the title bar's colors, text, and icon for brand consistency.</td></tr><tr><td>Interactive Enhancements</td><td>Features such as double-click maximize/restore add to the interactive user experience.</td></tr><tr><td>Ease of Integration</td><td>Properties are grouped logically and can be set during form initialization for immediate effect.</td></tr></tbody></table>

***

### Additional Code Example

Below is a complete integration sample demonstrating how to initialize a SiticoneForm with customized title bar properties:

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI; // Adjust namespace as needed

public class MainForm
{
    public static void Main()
    {
        var myForm = new SiticoneForm
        {
            FormTitle = "My Branded Application",
            TitleBarBackColor = Color.DodgerBlue,
            TitleBarForeColor = Color.White,
            FormTitleFont = new Font("Segoe UI", 11f, FontStyle.Bold),
            TitleLeftPadding = 15,
            Icon = new Icon("appIcon.ico"),
            IconSize = 24,
            EnableTitleBarDoubleClick = true
        };

        // Optional: Subscribe to title bar events if needed (e.g., double-click behavior is enabled by default)
        myForm.Load += (sender, e) =>
        {
            Console.WriteLine("Form loaded with customized title bar.");
        };

        Application.Run(myForm);
    }
}
```

***

### Additional Resources

| Resource               | Description                                                                                       | Link/Reference                                                                                             |
| ---------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| Code Comments          | The inline comments in the provided code explain how title bar properties are applied.            | Refer to the provided code snippet.                                                                        |
| Official WinForms Docs | Microsoft’s documentation on WinForms provides further details on customizing forms and controls. | [https://docs.microsoft.com/dotnet/desktop/winforms/](https://docs.microsoft.com/dotnet/desktop/winforms/) |
| Community Forums       | Developer forums and communities can be useful for real-world usage tips and troubleshooting.     | Check .NET or WinForms community sites.                                                                    |

***

This documentation should serve as a comprehensive guide for integrating and customizing the title bar of your SiticoneForm. Each section is designed to help developers understand the available options, follow best practices, and troubleshoot common issues while implementing the feature.
