1

I developed a Winforms application that has a Toolbar. The last element in the toolbar is a ToolStripDropDownButton with some items.

I needed this button to be shown apart from all other toolbar buttons, so I set the Alignment property to right.

In my PC this works perfectly, however, when I moved the whole Visual Studio project to my notebook and then ran the application, the menu items are not shown when I click the button, however, the dropdown button changes color indicating that it was selected.

At design time, items are shown correctly.

What is happening here and is it possible to solve it? At the moment, I set the button alignment to left, so that it is shown together with other toolbar buttons.

Thanks Jaime

jstuardo
  • 3,901
  • 14
  • 61
  • 136

1 Answers1

0

Check your DPI settings on your notebook. It is likely changing the size and padding of your elements. You can get around this by checking for the system's DPI value and calculating sizes of controls based on that.

var graphics = this.CreateGraphics();
var dpiX = graphics.DpiX / 96d; // Default DPI
var dpiY = graphics.DpiY / 96d; // Default DPI
myToolbar.Width = myWidth * dpiX;
myToolbar.Height= myHeight * dpiY;
DunningKrugerEffect
  • 603
  • 1
  • 5
  • 18
  • you were right... dpi of notebook was changed, but I did not need to do that workaround. The problem was that I had the external monitor connector connected to it. With it, notebook DPI was changed, I think to fit the screen extension using the monitor. – jstuardo Mar 31 '16 at 18:13
  • I've noticed that external monitors can have weird effects on DPI settings. You can have 100% DPI on your main display, but 120% on a secondary. When you check for DPI settings programmatically you can get mixed results, and it can be difficult to account for. – DunningKrugerEffect Mar 31 '16 at 19:25