Skip to content

Fix ComboBox dropdown height after clearing or removing all items#14632

Open
JayashreeSF3546 wants to merge 6 commits into
dotnet:mainfrom
JayashreeSF3546:339
Open

Fix ComboBox dropdown height after clearing or removing all items#14632
JayashreeSF3546 wants to merge 6 commits into
dotnet:mainfrom
JayashreeSF3546:339

Conversation

@JayashreeSF3546

@JayashreeSF3546 JayashreeSF3546 commented Jun 10, 2026

Copy link
Copy Markdown

Fixes #339

Proposed changes

  • Update ComboBoxChildNativeWindow handling for the dropdown list window.
  • Intercept WM_WINDOWPOSCHANGING for the native dropdown LISTBOX and update WINDOWPOS.cy with the managed calculated dropdown height.
  • Ensure dropdown height reflects current Items.Count / DropDownHeight even after Items.Clear() or removing the last item.

Customer Impact

  • Fixes incorrect ComboBox dropdown height after items are cleared or removed at runtime.
  • Prevents the dropdown from using a stale native cached height when the item count becomes zero.

Regression?

  • No

Risk

  • Low.
  • The change is limited to the ComboBox dropdown LISTBOX window during WM_WINDOWPOSCHANGING.
  • The fix only updates height when the native window position change includes sizing and does not affect other child window types.
  • Existing IntegralHeight behavior is preserved while ensuring the final committed dropdown height matches WinForms calculated height.

Screenshots

Before

image

After

image

Test methodology

  • Added/updated unit test coverage to verify WM_WINDOWPOSCHANGING updates WINDOWPOS.cy to the managed calculated dropdown height.
  • Verified the dropdown height is corrected after Items.Clear().
  • Verified the fix does not update height when SWP_NOSIZE is set.

Accessibility testing

  • No accessibility behavior change expected.
  • The change only corrects the native dropdown LISTBOX height calculation.
  • No changes were made to accessible names, roles, states, keyboard navigation, or UI Automation patterns.

Test environment(s)

  • Windows 11
  • .NET SDK: 11.0.100-preview.3.26170.106
Microsoft Reviewers: Open in CodeFlow

@JayashreeSF3546 JayashreeSF3546 requested a review from a team as a code owner June 10, 2026 12:04
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.

The height of the "DropDown" list for the combobox control can't be reset default height after called the " comboBox1.Items.Clear();" method

1 participant