Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions dotnet-desktop-guide/winforms/whats-new/net110.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Each release announcement provides detailed information about Windows Forms chan

## Visual styles and appearance

`System.Windows.Forms.Application.SetDefaultVisualStylesMode` and the new `System.Windows.Forms.Control.VisualStylesMode` property provide an application and control-level opt-in for a refreshed rendering pipeline. Choose between the classic renderer (`VisualStylesMode.Classic`), visual styles turned off entirely (`VisualStylesMode.Disabled`), and the modern renderer (`VisualStylesMode.Net11`). `VisualStylesMode.Latest` always resolves to the newest mode the runtime supports. Child controls default to `VisualStylesMode.Inherit`, so the setting cascades from parent to child.
`System.Windows.Forms.Application.SetDefaultVisualStylesMode` and the new `System.Windows.Forms.Control.VisualStylesMode` property let you opt in to a refreshed rendering pipeline at the application and control level. Choose between the classic renderer (`VisualStylesMode.Classic`), visual styles turned off entirely (`VisualStylesMode.Disabled`), and the modern renderer (`VisualStylesMode.Net11`). `VisualStylesMode.Latest` always resolves to the newest mode the runtime supports. Child controls default to `VisualStylesMode.Inherit`, so the setting cascades from parent to child.

The `Net11` mode brings modernized rendering for `Button`, `CheckBox`, `RadioButton`, `GroupBox`, `TextBox`, and `RichTextBox`. The `FlatStyle` property on buttons and checkboxes, and the `BorderStyle` property on text boxes, define the render style used. The `Padding` property on text boxes and rich text boxes is now accessible in the Property Grid and is applied when `VisualStylesMode` is `Net11` or newer.
The `Net11` mode brings modernized rendering for `Button`, `CheckBox`, `RadioButton`, `GroupBox`, `TextBox`, and `RichTextBox`. The `FlatStyle` property on buttons and checkboxes, and the `BorderStyle` property on text boxes, define the render style. The Property Grid now exposes the `Padding` property on text boxes and rich text boxes, and applies it when `VisualStylesMode` is `Net11` or newer.

`Control.VisualStylesMode` is an ambient property, similar to `BackColor` or `Font`. Resolution walks up the parent chain, and when it reaches the top level, it falls through to `Application.DefaultVisualStylesMode`. Call `Control.GetVisualStylesModeChangeImpact` to report what needs updating when modes change, and `EffectiveVisualStylesMode` to retrieve the resolved value after inheritance.
`Control.VisualStylesMode` is an ambient property, similar to `BackColor` or `Font`. Resolution walks up the parent chain, and when it reaches the top level, it falls through to `Application.DefaultVisualStylesMode`. Call `Control.GetVisualStylesModeChangeImpact` to see what needs updating when modes change, and use the `Control.EffectiveVisualStylesMode` property to get the resolved value after inheritance.

```csharp
using System.Windows.Forms;
Expand All @@ -55,7 +55,7 @@ Application.Run(form);

## React to system visual settings

`System.Windows.Forms.Application.SystemVisualSettings` exposes accent color, high-contrast state, keyboard-cue visibility, client-area animation settings, focus-border metrics, and text scale factor as a single snapshot. The new `System.Windows.Forms.Application.SystemVisualSettingsChanged` event fires whenever one of those categories changes. Update only the affected UI instead of rebuilding theme resources on every notification. `System.Windows.Forms.SystemVisualSettingsChangedEventArgs.Changed` is a `SystemVisualSettingsCategories` flags value that indicates which categories changed. Controls can override `OnSystemVisualSettingsChanged` to respond locally.
`System.Windows.Forms.Application.SystemVisualSettings` exposes accent color, high-contrast state, keyboard-cue visibility, client-area animation settings, focus-border metrics, and text scale factor as a single snapshot. The new `System.Windows.Forms.Application.SystemVisualSettingsChanged` event fires whenever one of those categories changes, so you can update only the affected UI instead of rebuilding theme resources on every notification. `System.Windows.Forms.SystemVisualSettingsChangedEventArgs.Changed` is a `SystemVisualSettingsCategories` flags value that indicates which categories changed. Controls can override `OnSystemVisualSettingsChanged` to respond locally.

```csharp
using System.Drawing;
Expand All @@ -78,7 +78,7 @@ Application.SystemVisualSettingsChanged += (sender, e) =>

## Deferred form reveal

`System.Windows.Forms.FormRevealMode` gives applications control over when a form becomes visible during startup. `FormRevealMode.Deferred` keeps a form concealed until its initial layout and theming settle, avoiding the brief flash of an unstyled window when dark mode or the new visual styles apply after the form first shows. `FormRevealMode.Classic` preserves the existing show-immediately behavior, and `FormRevealMode.Inherit` follows the value set with `Application.SetDefaultFormRevealMode`. Call `Application.IsFormRevealDeferred` to report the resolved state, and handle the `Form.FormRevealModeChanged` event when the value changes.
`System.Windows.Forms.FormRevealMode` gives applications control over when a form becomes visible during startup. `FormRevealMode.Deferred` keeps a form concealed until its initial layout and theming settle, avoiding the brief flash of an unstyled window when dark mode or the new visual styles apply after the form first shows. `FormRevealMode.Classic` preserves the existing show-immediately behavior, and `FormRevealMode.Inherit` follows the value set with `Application.SetDefaultFormRevealMode`. Call `Application.IsFormRevealDeferred` to get the resolved state, and handle the `Form.FormRevealModeChanged` event when the value changes.

```csharp
using System.Windows.Forms;
Expand All @@ -92,7 +92,7 @@ Application.Run(form);

## Suspend painting during bulk mutations

The new `System.Windows.Forms.ISupportSuspendPainting` interface and the `ControlMutationExtensions.SuspendPainting` extension method combine `BeginUpdate`/`EndUpdate` and `SuspendLayout`/`ResumeLayout` into a single `IDisposable` scope. `LayoutSuspendTraversal` controls whether the suspension applies to the target only or to the target and all of its descendants. This is particularly useful when applying changes to nested `TableLayoutPanel` containers with auto-sizing, where suspension prevents layout storms and flicker.
The new `System.Windows.Forms.ISupportSuspendPainting` interface and the `ControlMutationExtensions.SuspendPainting` extension method combine `BeginUpdate`/`EndUpdate` and `SuspendLayout`/`ResumeLayout` into a single `IDisposable` scope. `LayoutSuspendTraversal` controls whether the suspension applies to the target only or to the target and all of its descendants. This approach is useful when you apply changes to nested `TableLayoutPanel` containers with auto-sizing, where suspension prevents layout storms and flicker.

<xref:System.Windows.Forms.ComboBox>, <xref:System.Windows.Forms.ListBox>, <xref:System.Windows.Forms.ListView>, <xref:System.Windows.Forms.RichTextBox>, and <xref:System.Windows.Forms.TreeView> now implement `ISupportSuspendPainting`. They route their established suspension patterns (`BeginUpdate`/`EndUpdate`) through the new interface, so bulk edits avoid flicker without managing multiple paired calls. For all other controls, the suspension behavior is new.

Expand All @@ -112,7 +112,7 @@ using (list.SuspendPainting(LayoutSuspendTraversal.Target))

## Toggle-switch appearance for CheckBox and RadioButton

`System.Windows.Forms.Appearance.ToggleSwitch` is a new value for `System.Windows.Forms.CheckBox.Appearance` that renders the control as a switch under `VisualStylesMode.Net11`. Existing `Checked`, `CheckedChanged`, and data-binding behavior stays unchanged, so you don't need code updates when switching a `CheckBox` to the new appearance. Modernize checkbox controls to align with contemporary UI conventions without breaking changes.
`System.Windows.Forms.Appearance.ToggleSwitch` is a new value for <xref:System.Windows.Forms.CheckBox.Appearance?displayProperty=nameWithType> that renders the control as a switch under `VisualStylesMode.Net11`. Existing `Checked`, `CheckedChanged`, and data-binding behavior stays unchanged, so you don't need code updates when you switch a `CheckBox` to the new appearance. You can modernize checkbox controls to align with contemporary UI conventions without encountering breaking changes.

```csharp
using System.Windows.Forms;
Expand All @@ -126,17 +126,17 @@ CheckBox toggle = new()
```

> [!IMPORTANT]
> Rendering behavior for Visual Styles and the associated new APIs is not yet final and will continue to change until .NET 11 reaches GA. Based on exploratory testing and customer feedback, controls using non-classic Visual Style settings may occupy more or less space in upcoming .NET 11 releases (RC, GA) than they do in Preview 7. The behavior of the new APIs may likewise change in detail or in specific scenarios.
> Rendering behavior for Visual Styles and the associated new APIs isn't final yet and continues to change until .NET 11 reaches GA. Based on exploratory testing and customer feedback, controls using non-classic Visual Style settings might occupy more or less space in upcoming .NET 11 releases (RC, GA) than they do in Preview 7. The behavior of the new APIs might likewise change in detail or in specific scenarios.
>
> For this reason we recommend avoiding pixel-perfect design when adopting these features. Prefer layout-based approaches using `TableLayoutPanel` and `FlowLayoutPanel`, which adapt automatically to changes in control metrics.
> For this reason, avoid pixel-perfect design when you adopt these features. Prefer layout-based approaches using `TableLayoutPanel` and `FlowLayoutPanel`, which adapt automatically to changes in control metrics.

## Clipboard

- <xref:System.Windows.Forms.Clipboard.GetText*?displayProperty=nameWithType> with <xref:System.Windows.Forms.TextDataFormat.Rtf?displayProperty=nameWithType> now correctly reads RTF clipboard data that doesn't include a null terminator. This fix resolves an issue where valid RTF content copied from applications such as PowerPoint returned an empty string.

- <xref:System.Windows.Forms.Clipboard.GetDataObject> returns an `IDataObject` that can contain bitmap data placed on the clipboard, and <xref:System.Windows.Forms.DataObject.GetImage> retrieves the bitmap image from that data object. <xref:System.Windows.Forms.Clipboard.GetImage> also retrieves the image directly from the clipboard. <xref:System.Windows.Forms.DataObject.GetImage> now retrieves images through the typed clipboard pipeline by calling `TryGetData<Image>(DataFormats.Bitmap, autoConvert: true, ...)` and returns `null` when it can't retrieve an image.

The following code now round-trips bitmap images when `bitmap` is an existing <xref:System.Drawing.Bitmap> and you retrieve the image through the returned data object:
The following code now round-trips bitmap images when `bitmap` is an existing <xref:System.Drawing.Bitmap> and you get the image through the returned data object:

```csharp
// Round-trips again on .NET 11
Expand All @@ -146,13 +146,13 @@ CheckBox toggle = new()

## ToolStrip

- <xref:System.Windows.Forms.ToolStripDropDown> now preserves modal menu tracking during focus changes, allowing SmartTag and dropdown UI to close normally when users switch tab pages or move focus to other controls. This fixes a regression that caused dropdowns to remain open inappropriately.
- <xref:System.Windows.Forms.ToolStripDropDown> now preserves modal menu tracking during focus changes, so SmartTag and dropdown UI close normally when users switch tab pages or move focus to other controls. This fixes a regression that caused dropdowns to remain open inappropriately.

- <xref:System.Windows.Forms.ToolStrip> controls with `TabStop=true` no longer incorrectly activate menu handling after tab navigation. Previously, this behavior prevented controls such as <xref:System.Windows.Forms.TreeView> from receiving arrow key input.

- <xref:System.Windows.Forms.ToolStripDropDownMenu> scrolling now correctly handles menu boundaries without out-of-range scrolling or unintentionally dismissing the dropdown.

- <xref:System.Windows.Forms.ToolStrip> DPI changes now preserve the previous device DPI during the DPI change path, allowing scaling logic to run correctly when moving controls between displays with different DPI settings.
- <xref:System.Windows.Forms.ToolStrip> DPI changes now preserve the previous device DPI during the DPI change path, so scaling logic runs correctly when you move controls between displays with different DPI settings.

## Layout

Expand All @@ -162,7 +162,7 @@ CheckBox toggle = new()

- Hosted Windows Forms designers can now paste controls through `CommandSet.OnMenuPaste` again, restoring paste functionality that was previously broken.

- Collection editor captions for custom controls now display the underlying control type instead of the generated `ControlProxy<T>` wrapper name, providing clearer identification in the designer.
- Collection editor captions for custom controls now display the underlying control type instead of the generated `ControlProxy<T>` wrapper name, making it easier to identify controls in the designer.

## PropertyGrid

Expand All @@ -178,9 +178,9 @@ CheckBox toggle = new()

- <xref:System.Windows.Forms.ListBox>: `IsSynchronized` values are now correct across `ListBox` collections.

- <xref:System.Windows.Forms.NumericUpDown>: Button rendering regression when visual styles are disabled is fixed.
- <xref:System.Windows.Forms.NumericUpDown>: The button rendering regression that occurred when visual styles are disabled is fixed.

- <xref:System.Windows.Forms.SplitContainer>: Transient GDI+ `ExternalException` during display-session transition when calling `RepaintSplitterRect` is now handled.
- <xref:System.Windows.Forms.SplitContainer>: The control now handles a transient GDI+ `ExternalException` during display-session transition when calling `RepaintSplitterRect`.

- <xref:System.Windows.Forms.ToolStrip>: The scroll-down button no longer throws when scrolling. Indeterminate and checked `ToolStripMenuItem` icons are now visible in dark mode.

Expand Down
Loading