To reproduce:
- Set your monitor DPI to 200%(or any order value different from 100%). You need to Log off(or restart) in order to apply correctly the new DPI settings.
- Create a UserControl with some RadControls inside.
- Add the UserControl at design time as a child control to a RadForm.
- Run the RadForm and you will see that the controls inside the user control are scaled twice.
Workaround:
In the OnLoad method of RadForm do through all nested RadControls inside the UserControl and downscale them to the same DPI as the RadForm.
public class RadForm1 : RadForm
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
SizeF dpiScaleFactor = RootElement.DpiScaleFactor;
FixDpiScaling(this.Controls, dpiScaleFactor);
}
private void FixDpiScaling(Control.ControlCollection controls, SizeF dpiScaleFactor)
{
foreach (Control item in controls)
{
RadControl radControl = item as RadControl;
if (radControl != null)
{
SizeF dpi2 = radControl.RootElement.DpiScaleFactor;
if (dpiScaleFactor.Width != dpi2.Width)
{
SizeF fixDpiCoefficient = new SizeF(dpiScaleFactor.Width / dpi2.Width, dpiScaleFactor.Height / dpi2.Height);
radControl.Scale(fixDpiCoefficient);
}
}
FixDpiScaling(item.Controls, dpiScaleFactor);
}
}
}