Skip to content
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

Exception pops up when moving the mouse wheel up or down in ShortcutKeys property #12982

Open
Olina-Zhang opened this issue Feb 20, 2025 · 1 comment
Assignees
Labels
💥 regression-release Regression from a public release
Milestone

Comments

@Olina-Zhang
Copy link
Member

.NET version

.NET 10 SDK build: 10.0.100-preview.2.25118.3

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes, cannot repro in .NET 6.0/7.0, regression from .NET 8.0

Issue description

Exception pops up when moving the mouse wheel up or down in ShortcutKeys property. Repro in .NET 10/9/8, cannot in .NET6/7

Image

ShortcutKeysException.mp4

Debug log:
System.ComponentModel.InvalidEnumArgumentException
HResult=0x80070057
Message=The value of argument 'value' (65536) is invalid for Enum type 'Keys'. (Parameter 'value')
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.ToolStripMenuItem.set_ShortcutKeys(Keys value) in C:\Users\v-olzhan\source\repos\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Controls\ToolStrips\ToolStripMenuItem.cs:line 365
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Steps to reproduce

  1. Create a Winforms .NET application with menuStrip and propertyGrid controls added
  2. Add a toolStripMenuItem1 in menuStrip
  3. Set propertyGrid's SelectedObject to toolStripMenuItem1
  4. Build and run application
  5. Find ShortcutKeys property in propertyGrid, click (None) value, then move the mouse wheel up or down
@Olina-Zhang Olina-Zhang added untriaged The team needs to look at this issue in the next triage 💥 regression-release Regression from a public release labels Feb 20, 2025
@Tanya-Solyanik Tanya-Solyanik self-assigned this Feb 20, 2025
@Tanya-Solyanik Tanya-Solyanik added this to the 10.0 Preview3 milestone Feb 20, 2025
@Tanya-Solyanik Tanya-Solyanik removed the untriaged The team needs to look at this issue in the next triage label Feb 20, 2025
@Tanya-Solyanik
Copy link
Member

Tanya-Solyanik commented Feb 27, 2025

ToolStripMenuItem.ShortcutKeys property type (Keys enum) has a TypeConverter that reports that it has a set of standard values. This is not entirely accurate. Keys type has a set of standard values, but the ShortcutKeys property does not, even the ShortcuKeys type contains different key combinations from what can be generated by the shortcut editor. Shortcuts are combinations of keys and modifiers, it's not practical to present all combinations for user to step through with up/down keys or with mouse wheel. I would like to add a new TypeConverter to this property. KeysConverter is defined on the Keys enum, the property does not have one right now. This change is considered "borderline" allowed depending on whether this is considered a changed attribute or a new one https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/breaking-change-rules.md#attributes.

This behavior regressed when we added Keys.None to the list of standard values - #8401. This was done to localize None in the property browser UI. When the current value of the shortcut is not one of the standard values, property grid entry does not enter the "scroll through the standard items" functionality - highlighted methods in the below stacks.

The same happens on the arrow navigation
System.Windows.Forms.ToolStripMenuItem.ShortcutKeys.set Line 366
[Lightweight Function] Annotated Frame
System.Reflection.MethodBaseInvoker.InvokeWithOneArg
System.ComponentModel.ReflectPropertyDescriptor.SetValue
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValueCore Line 749
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValue Line 665
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.PropertyValue.set Line 222
System.Windows.Forms.PropertyGridInternal.PropertyGridView.CommitValue Line 4658
System.Windows.Forms.PropertyGridInternal.PropertyGridView.ProcessEnumUpAndDown Line 2477
System.Windows.Forms.PropertyGridInternal.PropertyGridView.OnEditKeyDown Line 2497
System.Windows.Forms.Control.OnKeyDown Line 7636
System.Windows.Forms.PropertyGridInternal.PropertyGridView.GridViewTextBox.OnKeyDown Line 150
System.Windows.Forms.Control.ProcessKeyEventArgs Line 8883
System.Windows.Forms.Control.ProcessKeyMessage Line 8923
System.Windows.Forms.Control.WmKeyChar Line 11356
System.Windows.Forms.Control.WndProc Line 12291

Mouse wheel is supported for enumerable values, i.e. values with the standard values set.
System.Windows.Forms.ToolStripMenuItem.ShortcutKeys.set Line 366
[Lightweight Function] Annotated Frame
System.Reflection.MethodBaseInvoker.InvokeWithOneArg
System.ComponentModel.ReflectPropertyDescriptor.SetValue
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValueCore Line 749
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValue Line 665
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.PropertyValue.set Line 222
System.Windows.Forms.PropertyGridInternal.PropertyGridView.CommitValue Line 4658
System.Windows.Forms.PropertyGridInternal.PropertyGridView.CommitValue Line 4622
System.Windows.Forms.PropertyGridInternal.PropertyGridView.OnMouseWheel Line 3155
System.Windows.Forms.Control.WmMouseWheel Line 11620
System.Windows.Forms.Control.WndProc Line 12429
System.Windows.Forms.PropertyGridInternal.PropertyGridView.WndProc Line 5367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 regression-release Regression from a public release
Projects
None yet
Development

No branches or pull requests

2 participants