Skip to content

Fix issue 14624: [PropertyGrid] FolderNameEditor does not use the modern FolderBrowserDialog#14635

Open
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14624
Open

Fix issue 14624: [PropertyGrid] FolderNameEditor does not use the modern FolderBrowserDialog#14635
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14624

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Fixes #14624

Proposed changes

  • Before the FolderNameEditor used for folder paths in a PropertyGrid is the old folder browser, which is a system component control and called by FolderBrowserHelper
  • Now use the modern FolderBrowserDialog to instead the old one, which is also a system component control and called by PInvokeCore.CoCreateInstance;
  • Refactoring Unit Tests - FolderNameEditorTests.cs

Customer Impact

  • [PropertyGrid] FolderNameEditor use the modern FolderBrowserDialog

Regression?

  • No

Risk

  • Mini

Screenshots

Before

14624-before.mp4

After

14624.mp4

Test methodology

  • Manual testing

Test environment(s)

  • 11.0.100-preview.5.26227.104

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WinForms design-time FolderNameEditor used by PropertyGrid so it uses System.Windows.Forms.FolderBrowserDialog (which supports the modern/Vista-style folder picker when AutoUpgradeEnabled is enabled), and adjusts related design-time editors and tests accordingly.

Changes:

  • Replaced the legacy FolderNameEditor.FolderBrowser usage with FolderBrowserDialog, and updated returned path handling to use SelectedPath.
  • Updated SelectedPathEditor / InitialDirectoryEditor overrides to match the new InitializeDialog signature.
  • Refactored/updated unit + UI integration tests and adjusted shipped public API text for the signature change.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.cs Switches the editor implementation to FolderBrowserDialog and updates InitializeDialog signature.
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectedPathEditor.cs Updates override to configure the new dialog type.
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InitialDirectoryEditor.cs Updates override to configure the new dialog type.
src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt Updates the shipped API entry for FolderNameEditor.InitializeDialog.
src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FolderNameEditorTests.cs Refactors unit tests around the new dialog type/signature.
src/test/integration/UIIntegrationTests/FolderNameEditorTests.cs Updates UI integration test to use FolderBrowserDialog / SelectedPath.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/test/integration/UIIntegrationTests/FolderNameEditorTests.cs Outdated

@LeafShi1 LeafShi1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I have a few concerns — see inline comments.

Comment thread src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt Outdated
Comment thread src/test/integration/UIIntegrationTests/FolderNameEditorTests.cs
@SimonZhao888 SimonZhao888 added the waiting-review This item is waiting on review by one or more members of team label Jun 15, 2026
@SimonZhao888

SimonZhao888 commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@KlausLoeffelmann we use the modern FolderBrowseDialog to replace the old Dialog, and as we cannot render a tabbed layout within the dialog's UI, and the descriptive information displayed on the old form is no longer applicable to the new one.
Older:
image
Modern Dialog:
image

I need to add a title to the dialog interface to indicate the corresponding attribute. Such as following:
image
and
image
Do you have any suggestions?

@KlausLoeffelmann

Copy link
Copy Markdown
Member

Let's talk about that in the meeting.
I was under the impression, this is just a generic folder picker.
Maybe I need some help to understand the exact context better! 😸

@SimonZhao888

Copy link
Copy Markdown
Member Author

FolderBrowserDialog prioritizes the modern Vista-style dialog; if that is not supported, WinForms automatically falls back to the legacy dialog. The code is as follows:

protected override bool RunDialog(IntPtr hwndOwner) =>
// If running the Vista dialog fails (e.g. on Server Core), we fall back to the
// legacy dialog.
UseVistaDialogInternal && TryRunDialogVista((HWND)hwndOwner, out bool returnValue)
? returnValue
: RunDialogOld((HWND)hwndOwner);

@KlausLoeffelmann

Copy link
Copy Markdown
Member

I thought about that.
I think we should take it like that, and having the distinction in the title makes it sufficiently clear.

Just to be sure:
For the different TypeEditors, you are adjusting the respective Text ("Selected Path", "Initial Directory") in the dialog title, correct?

If that is the case, and with the fall-back to the classic folder dialog for headless system, let's take this!

Thanks!

@KlausLoeffelmann KlausLoeffelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the signature change only after I wrote the comment.
So...we're no longer compatible to the OOP Designer then is my stomach feeling - let's check this first.

/// Initializes the folder browser dialog when it is created. This gives you an opportunity
/// to configure the dialog as you please. The default implementation provides a generic folder browser.
/// </summary>
[Obsolete]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeafShi1, @SimonZhao888:
If we change the signature of that method here, are we then still compatible with projecting the editor into framework from the OOP Designer?

@SimonZhao888 SimonZhao888 Jul 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlausLoeffelmann, impact on designer projection risks:
Virtually none.
The reason is:

  • The EditValue code here is not executed at design time,
  • so it is unaffected by the signature change in InitializeDialog(...).
  • Even if OOP Designer or framework projection mechanisms exist, they do not operate via this specific code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-review This item is waiting on review by one or more members of team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PropertyGrid] FolderNameEditor does not use the modern FolderBrowserDialog

4 participants