AutoScale Factor is not updating properly when we switch the scaling

303 views Asked by At

Issue: Edge of the control is clipped off when swtich scaling.

Windows OS:10

Im using Usercontrol which is inherited from Control in DpiAware Enabled application, I need to scale the control according to current scaling when

AutoScaleMode.Font

set in Form.Currently in 100 scaling if i drag and drop Usercontrol and run the application, the control will rendered properly with defined width and height.Now changing Scaling from 100 to 200 and running same the application the control needs to AutoScaled according to 200 scaling but here im facing issue height and width of the control is not updating properly [edge of control is clipped off].This issue may due to AutoScale factor is not updating properly, At this time if i opened designer of the application

AutoScaleDimensions
value of the form is changed according to current scaling, Now again im running the application the control will rendered properly.

AutoScaleFactor value is not updated properly in below override function

protected override Rectangle GetScaledBounds(Rectangle bounds, SizeF factor, BoundsSpecified specified)
{
    return base.GetScaledBounds(bounds, factor, specified);
}

Form AutoScaleDimensions Value

This may be due AutoScaleDimension value of Form is not updating when we switch the scaling. The (AutoScaleDimension (6F,13F) for 100 scaling) will maintaining for all scaling. But we open the designer before run the application the AutoScaleDimension value updated correctly its value according to corresponding scaling and the reported issue will get resolved now.

Before Opening Designer

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

After Opening Designer

this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

Please suggest me how to fix the reported issue.

0

There are 0 answers