This is a migrated thread and some comments may be shown as answers.

Font Size

6 Answers 1340 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 17 Jul 2020, 03:49 PM

Hello When I change the font of a radmaskededitbox, the font family changes correctly, but the size seems to be wrong.

here is how I change the font:

                            Dim meb As RadMaskedEditBox = TryCast(ctrl, RadMaskedEditBox)
                            meb.Font = NewFont
                            meb.Controls(0).Font = NewFont
                            meb.MaskedEditBoxElement.Font = NewFont

Atteched a screen copy where all controls fonts are set to "Comic Sans MS;9pt" and the radeditmaskedboxes show larger fonts

Any suggestion ...

thanks in advance

Pierre-Jean

6 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 20 Jul 2020, 12:34 PM

Hello, Pierre-Jean,

Following the provided information, I was not able to observe this behavior on my end. The font family, as well as the font size, is applied to RadMaskedEditBox. The result is demonstrated below:

Font newFont = new Font("Comic Sans MS", 9, FontStyle.Regular);
this.radMaskedEditBox1.Font = newFont;

I have attached my test project for your reference. Could you please refer to it and let me know how it differs from your set up?

I am looking forward to your reply.

Regards,
Nadya
Progress Telerik

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 21 Jul 2020, 02:27 PM

Hello Nadya, thanks for your message and the time spent on this issue

I have no problem with your test program, nor with a Test Program I tried to develop to illustrate the problem !!!

However I have made, I believe, some progress in identifying the source of this problem.
I belelieve it is related to my development environment which is a 4K display (3840x2160 @150%)
When I set the display to 100% I no longer have the problem (however I have greate difficulties reading the screen !!!)
The one thing I do not understand is that either your test program or mine do not show the problem even at 150%.
I have compared all my program settings related to the high DPI in App.Config and manifest,  I see no difference.
In both projects I have the autoscale parameter set to "None" (When I set autoscale to "Font" the font size adjusts correctly but the remainder of the forms becomes all wrong)

Would you have a suggestion on how to solve the problem.
incidentally I have the feeling the it is not the maskedEditBox font that is wrong but the other Controls (mostly RadTextBoxControls)

Ultimately this may not be critical as I expect my end-users to work at 100% but still I would feel more confortable having the answer to this question

Thanks a lot

Pierre-Jean

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Jul 2020, 01:48 PM

Hello, Pierre-Jean, 

I would like to note that in R2 2017 we introduced built-in HDPI support in the Telerik UI for WinForms suite. This coincides with the HDPI improvements Microsoft is bringing with .NET 4.7 and the Windows 10 Creators Update. The best part is that you will get this support no matter which .NET framework you are targeting (currently supported from .NET 2.0 and up).

All you will have to do is declare your application as DPI aware and RadControls will scale their UI elements in accordance to the current DPI settings automatically. To do that, you have to have an app.manifest file and/or an app.config file with several lines of code: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support

With the changes we introduced, the common problem of bad scaling when your applications run on high resolution monitors goes away, so your app will ship with higher quality on more systems instantly. The problem with the blurry fonts and unreadable texts will be eliminated and the potential of modern hardware will be utilized fully.

I would like to note that in order your form to be properly scaled when running the application at higher than 100% DPI scaling, it is necessary to be designed at 100%. In case your development machine has HDPI monitor and the scaling setting are larger than 100%, this can cause issues with the layout because opening the designer on such machines will set the AutoScaleDimensions property (the default value is SizeF(6F, 13F)) This property is used when a scaling factor is calculated and passed to your application. And if a wrong factor is passed the application can look smaller or larger then it should be. Please make sure that this property has its default value (SizeF(6F, 13F)) and execute any design time changes only at 100% DPI scaling.

There is a warning in Visual Studio that recommends developing on 100%: https://docs.microsoft.com/en-us/visualstudio/designers/disable-dpi-awareness?view=vs-2019

You can also consider using a TableLayoutPanel when creating a DPI-aware application. The main benefits are:

- The controls do not have specific location and size. This way when the form is resized the controls will fit in the available space.

- You can easily set Margin between the controls instead of using anchoring.

- The application will look better when it is scaled.

In case you are still experiencing any further undesired behavior when running the application at 150%, it would be greatly appreciated if you can provide a sample project demonstrating the problem you are facing. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 23 Jul 2020, 05:11 PM

Hello Dess

thanks a lot for your explanations,
I had most of the setups set as per your recommendations, I just had not understood I should set my display at 100% scale factor.
By doing this everything is now correct.

Just a last clarification, you mention "Please make sure that this property(AutoScaleDimensions" has its default value (SizeF(6F, 13F)) " but I have not found where to set this property.

Thanks in advance

Best regards

PJ

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jul 2020, 12:55 PM
Hello, Pierre-Jean, 

This property can be checked in the Designer.cs file. Since this file automatically serializes the changes performed at design time, please have in mind that it is not recommended to be changed manually. 

I would like to clarify that you should keep the DPI scaling at 100% only when you design your application in order to build correct layout and store the correct AutoScaleDimensions value. Once you are ready with designing, feel free to run the application at higher DPI scaling. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 25 Jul 2020, 11:54 AM

Hello Dess

Thanks for the clarification

Everything seems to be under control now

Thanks gain

Best Regards

Tags
MaskedEditBox
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or