Hi
I've got an application with several MDI-form, which are created dynamically at runtime. Every child-window has a toolstrip with a label and some buttons in it.The application has to adjust to the users DPI-setting. The
AutoScaleMode property is fine, but as i see it, it doesn't work for
the dynamically created MDIs. Because of this i scale them by myself
with the Scale method. This works quite good for everything but the
ToolStrip. The toolstrip scales only the buttons that are visible (not in overflow).
This is really annoying, and till now, i couldn't find a workaround. Hope someone can help me here.
It's easy to reproduce:
- create a new windows application
- add a toolstrip and a button to your form
- let your code look like this:
public Form1()
{
InitializeComponent();
Button bn1 = new Button();
bn1.Height = 22;
bn1.Width = 85;
bn1.Text = "Test1";
ToolStripControlHost tsch1 = new ToolStripControlHost(bn1);
tsch1.AutoSize = false;
toolStrip1.Items.Add(tsch1);
Button bn2 = new Button();
bn2.Height = 22;
bn2.Width = 85;
bn2.Text = "Test2";
ToolStripControlHost tsch2 = new ToolStripControlHost(bn2);
tsch2.AutoSize = false;
toolStrip1.Items.Add(tsch2);
}
private void button1_Click(object sender, EventArgs e)
{
this.Scale(new SizeF(1.5F, 1.5F));
}
Now
just start the app, resize the window so that one button gets pushed in
the overflow-menu. Press the scale-button and resize the window again.
You'll see that only the visible button got scaled!
Anybody got an idea how to get around this behaviour?