Reputation: 2452
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:
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
Upvotes: 5
Views: 1398
Reputation: 684
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)
Upvotes: 15
Reputation: 586
I see you adding items in Menu while its opening. Seems like the selected area and its width is already defined and its not reacting to the new data you inserted. What about trying to manually define width of Menu Item and see if that helps.
Upvotes: 0