-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Makes PropertyGrid for CoboBox show "(none)" when DataSource is null … #13860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceConverter.cs
Show resolved
Hide resolved
|
||
namespace System.Windows.Forms.Design; | ||
|
||
internal class DataSourceConverter : ReferenceConverter |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 baseListControl.DataSource
property instead of just theComboBox
. That way both inheriting controls get the same behavior.
I have updated the code and this is how it looks after the latest fix:
Thank you for the guidance!
9120a2b
to
c99c9b8
Compare
Fixes #12570
Root Cause
The
ComboBox.DataSource
property was missing aTypeConverter
to handle null value display inPropertyGrid
. WhenDataSource
is null,PropertyGrid
shows empty/blank instead of "(none)" text, breaking consistency with .NET Framework behavior and other similar properties likeDisplayMember
andValueMember
.Proposed changes
DataSourceConverter
class that inherits fromReferenceConverter
and converts null values to "(none)" for string displayTypeConverter
attribute toComboBox.DataSource
property to use the new converterCustomer Impact
Restores .NET Framework parity for PropertyGrid display. Developers using
PropertyGrid
to inspectComboBox
properties will now see consistent "(none)" text whenDataSource
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
After
Test methodology
DataSourceConverter
covering null conversion, culture handling, and edge casesPropertyGrid
andComboBox
to verify "(none)" displayTest environment(s)
Microsoft Reviewers: Open in CodeFlow