Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odd visual behavior from ToolStripMenuItem

I've got a Drop Down Menu that is dynamically filled every time it opens, here is the logic that does it:

private void joysticksToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
    _joysticks = _joystickWrapper.FindDevices(DeviceType.Joystick);
    joysticksToolStripMenuItem.DropDownItems.Clear();
    foreach (var di in _joysticks)
    {
        var item = new ToolStripMenuItem(di.ProductName);
        item.Checked = di.InstanceGuid == _joystickWrapper.CurrentDeviceInfo.InstanceGuid;
        joysticksToolStripMenuItem.DropDownItems.Add(item);
    }
}

When I run the application this is what I see:

That cant be right...

The check is in the wrong location and the blue area is too wide.

Any ideas on where to look to fix this? The entire menu is all System.Windows.Forms, no custom visual code in the entire application.

I tried on my current machine (Windows 10 Build 9926) and on my dev server (Server 2012R2) with the same results. I've also compiled this to the NET Framework 4.5 and 4.5.1

EDIT

For those interested, here is the git repo for this project:

https://github.com/adam8797/RovControl

like image 313
Adam Schiavone Avatar asked Mar 08 '15 19:03

Adam Schiavone


1 Answers

I came across this exact same issue and was finally able to resolve it by setting the ImageScalingSize property of the MenuStrip to 16,16 (it had somehow been set to 32,32, possibly due to my editing of the form on a high DPI machine)

like image 199
Daniel Simpkins Avatar answered Nov 16 '22 23:11

Daniel Simpkins