Skip to content

Conversation

ricardobossan
Copy link
Member

@ricardobossan ricardobossan commented Sep 11, 2025

Fixes #12570

Root Cause

The ComboBox.DataSource property was missing a TypeConverter to handle null value display in PropertyGrid. When DataSource is null, PropertyGrid shows empty/blank instead of "(none)" text, breaking consistency with .NET Framework behavior and other similar properties like DisplayMember and ValueMember.

Proposed changes

  • Created DataSourceConverter class that inherits from ReferenceConverter and converts null values to "(none)" for string display
  • Applied TypeConverter attribute to ComboBox.DataSource property to use the new converter
  • Added comprehensive unit tests to verify converter behavior across different cultures and scenarios

Customer Impact

Restores .NET Framework parity for PropertyGrid display. Developers using PropertyGrid to inspect ComboBox properties will now see consistent "(none)" text when DataSource is null, improving design-time experience.

Regression?

No. This is a missing feature/behavior that existed in .NET Framework but was lost in .NET Core migration.

Risk

Minimal.

Screenshots

Before

before

After

after

Test methodology

  • Unit tests for DataSourceConverter covering null conversion, culture handling, and edge cases
  • Manual testing with PropertyGrid and ComboBox to verify "(none)" display

Test environment(s)

  • 10.0.100-alpha.1.24573.1
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.11928%. Comparing base (8f9c849) to head (c99c9b8).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13860         +/-   ##
===================================================
- Coverage   77.12127%   77.11928%   -0.00199%     
===================================================
  Files           3273        3275          +2     
  Lines         644931      644936          +5     
  Branches       47692       47695          +3     
===================================================
- Hits          497379      497370          -9     
- Misses        143876      143892         +16     
+ Partials        3676        3674          -2     
Flag Coverage Δ
Debug 77.11928% <100.00000%> (-0.00199%) ⬇️
integration 18.99332% <0.00000%> (+0.00995%) ⬆️
production 51.95209% <100.00000%> (-0.00537%) ⬇️
test 97.41261% <100.00000%> (+0.00005%) ⬆️
unit 49.36262% <100.00000%> (-0.01304%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


namespace System.Windows.Forms.Design;

internal class DataSourceConverter : ReferenceConverter
Copy link
Member

Choose a reason for hiding this comment

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

If have a few questions here:

  • What was/is the behavior in NetFX here? Do we also have such a converter there?
  • Is this just for the ComboBox? How does the ListBox for example handle this?

Copy link
Member Author

@ricardobossan ricardobossan Sep 23, 2025

Choose a reason for hiding this comment

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

  • Yes, DataSourceConverter also exists in NetFX.

  • You're right! I should have added TypeConverter to the base ListControl.DataSource property instead of just the ComboBox. That way both inheriting controls get the same behavior.

I have updated the code and this is how it looks after the latest fix:

13860_LISTBOX_FIXED

Thank you for the guidance!

@ricardobossan ricardobossan force-pushed the Issue_12570_ComboBox_PropertyGrid_Empty branch from 9120a2b to c99c9b8 Compare September 23, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No "(none)" text display for the DataSource property in PropertyGrid control
4 participants