question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ContextMenuStrip doesn’t DPI-scale its items properly

See original GitHub issue

.NET Core Version

6.0.0-preview.3.21201.4

Have you experienced this same bug with .NET Framework? Didn’t bother to check; I no longer target .NET Framework

Problem description

The below screenshot illustrates the problem much better than words can. The left menu is the ContextMenuStrip; the right menu is a ToolStripMenuDropDown.

Expected behavior

All menu items should have the same height, no matter what kind of container they are located in.

Minimal repro

Screenshot

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
helviettcommented, Dec 1, 2022

IsHandleCreated for ContextMenuStrip when DPI changed? if not, it won’t receive any DPI change messages.

IsHandleCreated is always false for ContextMenuStrip.

I created a repro and found out that the main problem causes ToolStripItem.AutoSize property set to false. With AutoSize set to true menu items are resized correctly. However they still show wrong DeviceDpi and everything should be resized correctly with any AutoSize value.

ContextMenuStripDpiChangedTest.zip

1reaction
dreddy-workcommented, Jul 31, 2023

@wjk, seems two different issues were discussed in this thread and one of them doesn’t repro with lates. Please reactivate if you still see the issue with lates .NET 8.0 bits…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ContextMenuStrip doesn't DPI scale when Form is dragged ...
The ContextMenuStrip doesn't scale when its parent Form is dragged between monitors of different resolution/scaling. The ContextMenuStrip is ...
Read more >
Newest 'contextmenustrip' Questions
ContextMenuStrip doesn't DPI scale when Form is dragged between monitors with different resolution/scaling (WinForms, .
Read more >
ContextMenuStrip Class (System.Windows.Forms)
Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control. (Inherited from...
Read more >
How to disable default contect menu while in editmode
The easiest thing to do would be to set the ContextMenu on the grid control in the MouseMove or MouseDown events. You don't...
Read more >
TreeList Control (Experimental) - AutoHotkey Community
It doesn't crash for me after updating those but the control doesn't seem to properly get items added to it still. It appears...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found